Index

Note: Italicized page locators indicate a figure; tables are noted with a t.

A

  • ABListIterator, iterator class, 352353

  • abstract data types defined, 70

  • abstract keyword, 73

  • abstract methods

    • declaring, 73

    • defined, 72

  • abstraction, 6878

    • data abstraction, 6970

    • data levels, 7071

    • defined, 68

    • information hiding, 6869

    • Java interfaces, 7276

  • access modifiers

    • Java, 5t

    • purpose and use of, 56

  • activation record (stack frame), defined, 193

  • addresses, references as, 34

  • adjacency lists

    • defined, 596

    • representation of graphs with, 597

  • adjacency matrix, 591

    • defined, 591

    • representing edges in graph with, advantages, 596

  • adjacent vertices, defined, 588

  • ADTs. See abstract data types

  • algorithms

    • comparing, 4354

    • inefficient, recursive solution and, 198200

    • recursive, 163165

  • aliases, 3536

  • amortized analysis, 233

  • ancestors, 424, 425

  • anonymous inner class, 353354

  • application, 1012

    • (or user) level, of ADT, 70

  • array-based implementations

  • ArrayBlockingQueue, 282

  • ArrayBoundedQueue class, 223229

  • ArrayBoundedStack Class, 91137

  • ArrayCollection class, 301304

  • ArrayDeque class, 256

  • ArrayList class, 90, 99, 100, 123, 231, 565

  • ArrayList iterator method, 512

  • ArrayListMap.java, code for, 508511

  • ArrayListStack class, 99101

  • arrays, 28, 28, 3843

    • linked lists vs., 111113

    • of objects, 39

    • with references, sorting, 660

    • specifying size of, 38

    • two-dimensional, 4243

  • ArrayUnboundedQueue class, 230233

  • asterisk (*), in import declarations, 21

  • average case complexity, 45

  • average waiting time application, 257268

  • AVL trees, 484-485

B

  • B-trees, 483484

  • Bag ADT, 331-333

  • balance operation, for balancing binary search tree, 469

  • base case, defined, 165

  • BasicSet1.java, 334

  • BasicSet2.java, 335

  • best case complexity, 45

  • binary operators, 132

  • binary search, 47, 170174

  • binary search trees, 429435

    • balancing, 469471

      • iterative part of algorithm, 469

      • optimal transformation, 471

      • recursive part of algorithm, 469

    • classes and interfaces, UML diagram of relationships among, 486

    • defined, 432

    • implementation level

      • basics, 439443

      • remaining observers

        • add operation, 455460

        • contains and get operations, 449452

        • iteration, 448

        • remove operation, 460463

    • implementing priority queues and, 556

    • insertions into, 456

    • iterative approach to size method, 446448

    • iterative part of algorithm, 469

    • iterative vs. recursive method implementations, 443448

      • recursion or iteration?, 448

      • recursive approach to size method, 443448

    • performance

      • insertion order, 468

      • text analysis experiment, 466467

      • tree shape, 468469

    • property, 431432

    • recursive part of algorithm, 470

    • removals from, 463

    • restructuring, 469

    • two, 445

  • binary tree traversals, 433434

    • inorder traversal, 433

    • postorder traversal, 433

    • preorder traversal, 433

    • visualizing, 434

  • binary trees, 429431, 430, 431, 432, 485

    • defined, 429

    • full, 556

    • general, 557

    • height of, 431

    • nodes for, 440

    • as recursive structures, 424

  • boolean type, 27

  • bounded time O (1), 53

  • BoundedQueueInterface, code for, 222

  • breadth-first searching, airline-route graph and, 602605

  • breadth-first traversal

    • tree traversals, 426427

      • algorithm for, 427

  • BSTInterface interface, 436437, 440

  • BSTNode class, 457, 462

  • bubble sort, 631635

    • analyzing, 633635

    • basic algorithm for, 631

    • example of, 632

    • snapshot of algorithm, 633

  • buckets, 523

    • collisions and, 523

  • buffers, queues and, 220

  • by copy, collection ADT, 319320, 322

  • by reference, collection ADT, 319321, 322

  • by reference variables, by value variables vs., 35

  • by value variables, by reference variables vs., 35

  • byte code, Java, 191

  • byte type, 27

C

  • catch statement, 22, 27

  • char type, 27

  • children

    • in binary trees, 429

    • in trees, 31, 423

  • Circle class, 34, 73, 78, 84, 309

    • code for, 73

  • circular linked queue, 241

  • classes, 27

    • interfaces implemented by, 73

    • organizing, 1222

      • inheritance, 1219

      • packages, 1922

    • role of, 2

  • ClassPath directories, 21

  • clone operation, 143

  • clustering, 521

  • collection ADT, 298336

    • array-based implementation, 300304

    • assumptions, 299

    • BagInterface class, 331333

    • CollectionInterface class, 299

    • comparing objects, 308315

    • defined, 81

    • elements, 8184, 82

    • interface, 298300

    • link-based implementation, 325330

    • naming conventions, 325

    • primary classes and interfaces, 337

    • protected methods, 302

    • Set ADT, 333336

    • sorted array based implementation, 315324

  • CollectionInterface, 299, 435

    • code for, 300

    • method definitions, 331

  • collisions, 518519, 518519, 519

    • with buckets, 523

    • with chaining, 524

  • Comparable interface, 308, 314315

  • Comparable keys, 507

  • Comparable objects, 442

  • Comparator object, 507

  • compare method, 661

  • compareTo method, 308, 661, 662

    • operation consistency, 315

  • comparison operator (==), 37

  • compilation units, multiple, packages with, 20

  • complete binary tree, 557

  • complete directed graph, 587

  • complete graphs, 586

  • complete undirected graph, 587

  • compression function, 517, 518

  • concurrency, 283

    • Java Library Collection classes and, 282

  • concurrent programming, 269, 279

  • ConcurrentLinkedQueue, 282

  • constant time, 53

  • constants, capitalization of, 4

  • CSInfo application, 311313

  • Customer class, code for, 260262

  • CustomerGenerator class

  • cycle, defined, 586

D

  • Date class, 2, 34, 12, 16, 17, 23, 70

    • class diagram for, 8

    • days-between problem and, 10

  • DaysBetween program, code for, 11

  • DecimalFormat class, 472

  • decision trees, 479480

  • depth-first searching, 81, 598602

    • code for, 605

  • depth-first traversal

    • tree traversals, 428429

      • algorithm for, 429

  • depth of the recursion, defined, 195

  • DequeInterface class, 251, 256

  • dequeue operation, 219

    • fixed-front design approach in ArrayBoundedQueue class and, 224

    • floating-front design approach in ArrayBoundedQueue class and, 225, 226

    • heaps and, 559

    • link-based implementations for Queue ADT, 239241, 240

    • for Priority Queue ADT, 553

  • descendants, in binary trees, defined, 424

  • Dictionary class, 283

  • digraph, 584

  • direct addressing, 33

  • direct recursion, defined, 166

  • directed graph (digraph), 587, 588

  • disconnected graph, 586

  • disjoint subtrees, 423

  • DLLNode class, 253

  • double ended queue, 251

  • doubly linked lists, 252255

    • with two references, 388

  • dynamic binding, 19

  • dynamic memory management, defined, 37

  • dynamic programming, 200

  • dynamic storage allocation, recursion and, 193195

E

  • edges (arcs), 587

    • adding to graphs, 594

    • in graphs, 584

  • encapsulation, 69

  • enlarge method, ArrayUnboundedQueue class and, 230, 231

  • enqueue operation, 219

    • fixed-front design approach in ArrayBoundedQueue class and, 224

    • floating-front design approach in ArrayBoundedQueue class and, 225, 226

    • link-based implementations for Queue ADT, 238239, 239

    • for Priority Queue ADT, 555

  • equals method, 298, 308314

    • operation consistency, 315

  • Exception class, 24

  • exceptional situations, 2227

  • exponential time, O(2N), 5354

  • expression/parse trees, 480481

F

  • factorial method, 166, 193

    • iterative solution for, 167

    • recursive call in, 195

  • factory methods, 347

  • FamousPerson class, 310311

  • FIFO. See First in, first out

  • FigureInterface.java, 73-78

  • final modifier, purpose of, 4

  • first in, first out, 29

    • as priority queue, 552

    • queue operations, breadth-first searching and, 603

  • fixed-front design approach, for ArrayBoundedQueue class, 224225

  • float type, 27

  • floating-front design approach, for ArrayBoundedQueue class, 225

  • for-each loops, 347

  • fractals, 186190

  • full binary tree, 556

  • functional modularization, 10

G

  • garbage, 36-37

  • generic collections, 8384

  • getIterator

  • GlassQueueInterface class, 248250, 249

    • code for, 249

  • graph ADT, specification of, 589. See also graphs

  • graphical user interface (GUI), 107

  • graphs, 31

  • growth rates, comparison of, 54t

  • GUI approach, 109110, 406

    • list-related classes and interfaces, 409

H

  • hash-based map, 530539

  • hash code, 526

  • hash functions, in map ADT, 524530

    • array size, 524525

    • complexity, 530

    • defined, 526

    • Java’s support for, 529530

    • minimizing collisions with, 666

    • selecting, digitizing, and combining, 526527

    • things to consider, 527529

  • hash table, 516

  • hashCode method, 529

  • hashing

  • HashMap class, 283

  • HashSet class, 283

  • HashTable class, 283

  • header node, 381

  • Heap class, 608, 653

  • heap sort, general approach of, 652

  • heap values, in array representation, 562

  • HeapPriQ class

  • heaps, 556576

    • building, 652655

      • algorithm for, 653

      • changing contents of array, 654

      • process for, 654

    • defined, 556

    • dequeueing elements from, 559

    • enqueueing elements to, 560

    • implementation of, 562576

    • maximum, 557

    • other representations of priority queues vs., 575576

    • testing, 574575

  • hierarchical relationships, trees and modeling of, 423

  • high-probability ordering, 663664

  • HMap code, 531536

  • hybrid data structures, 541

I

  • immutable objects, 13

  • implementation dependent structures, 2829

    • arrays, 28

    • linked lists, 29

  • implementation independent structures, 2931

    • graphs, 31

    • queues, 2930

    • sorted lists, 30

    • stacks, 29

    • trees, 31

  • import statements, forms of, 21

  • indexed lists, 346

  • IndexedListInterface, code for, 348349

  • IndexOutOfBoundsException, 346

  • indirect addressing, 33

  • indirect recursion

    • defined, 166

    • remove operation and, 466

  • infix notation, 132

  • information hiding, 6869

  • inheritance, 5, 1219

    • extended class diagram for, 15

    • of interfaces, 249

  • inheritance based polymorphism, 1819

  • inheritance tree, 15, 1617

  • Inner class, iterator class, 353

  • inorder traversal, 434, 452

    • defined, 433

    • generating, 433

    • uses for, 437

    • visualizing, 434

  • input size, 46

  • insertionSort, 374, 635638, 638

    • algorithm of, 637

    • analyzing, 638

    • code for, 638

    • example of, 636

    • order of magnitude for, 666t

  • integrated testing, 9698

  • interactive test driver, Queue ADT, 234237

    • algorithm for implementation, 234

    • sample output, 236

  • interface keyword, 72

  • interfaces

    • benefits of, with ADT specifications, 7576

    • class implementation of, 73

    • example of, 73

    • in java, 7276

    • versatility and power of, 75

  • interference, threads and, 274275

  • ITDArrayBoundedQueue, 235

  • Iterable interface, 347, 435

  • iteration

    • Binary Search Tree ADT, 448

    • defined, 346

  • iterative approach, to size method, 446448

  • iterative solution, for factorial, 167

  • iterator

  • iterator() method, 347, 512

J

  • Java programming model, description of, 191

  • Java threads, 271274

  • Java Virtual Machine, executing, 10

  • Java’s Scanner, 307

  • Java’s support for

    • hash functions, in map ADT, 529530

    • map variations, 542

  • join command, 273, 274

K

  • key attribute, 298

  • Kids class, code for, 191192

L

  • large integers

    • internal representation, 387388

    • LargeInt object, 386

    • with linked list, 387

  • LargeInt class, 393

    • adding element to beginning, 391

    • addition rules, 402

    • helper methods, 396398, 400

    • subtraction, 403

  • leaf

    • in binary trees, defined, 425

    • removing, 461

  • leaf nodes, removing, 461

  • level-order traversal, 426

  • LIFO. See Last in, first out

  • Lilian Day Numbers, 3, 67, 10

  • lilian method, 10

  • linear linked lists, traversals, 426

  • linear probing

  • linear time, O(N), 53

  • link-based implementations

  • linked list, 28, 29, 111121

  • LinkedBlockingQueue, 282

  • LinkedCollection class, 334

  • LinkedGlassQueue class, 250

    • code for, 250

    • queue variations, 248

  • LinkedList class, 381

  • LinkedQueue class, 237

  • LinkedStack class, 122, 131, 197

  • list ADT, 345408

    • applications, 366373

    • array-based implementations for, 350355

    • assumptions about, 348

    • defined, 346

    • informal specification for, 348

    • iterable, 352

    • in Java Collections Framework, 346

    • link-based, 355360

  • List interface, 348350

  • list-related classes and interfaces, 409

  • LLNode class, 113115, 115, 122, 125, 129

    • code for, 115

  • logarithmic time, O (log2N), 53

  • logical (or abstract) level, of ADT, 7071

  • long type, 27

M

  • Map ADT, 499543

  • map implementations, 506512

    • array-based implementation, 508512

    • binary search tree, 508

    • sorted array, 507

    • sorted linked list, 508

    • unsorted array, 506507

    • unsorted linked list, 507

  • map variations, 539542

    • hybrid structure, 540542

    • Java support for, 542

  • MapEntry class

    • code for, 504

  • MapInterface, 501506

  • maximum heap, 557

    • shortest-path algorithm and, 608

  • merge sort, 639646

    • algorithm for, 639

    • analysis of algorithm with N = 16, 645

    • merging for sorted halves, 640, 642

  • mergeSort algorithm, analysis of, with N = 16, 644, 645

  • multi-tasking, defined, 268

N

  • N log N time, 53

  • naming constructs, 123

  • natural order of class, 314

  • nodes, 440

    • as ancestors of other nodes, 443

    • in binary trees, 429430, 440

    • in graphs, 31, 584

    • iterative method to counting of, on linked lists, 446

    • level of, 425

    • in linked lists, 112, 113

    • with only one child, removing, 461, 461

    • removing, methods for, 460462, 462

    • of trees, 423

    • with two children, removing, 461, 462

    • without subtrees, determining, 445

  • nonprimitive variables, primitive variables vs., 37, 309

  • null reference, 9, 34

  • null value, 113

  • NullPointerException, 128

O

  • Object class, 16, 1719, 82, 83, 92

  • objects, 810

    • aliases and, 3536

    • array of, 39

    • changing to strings, 16

    • comparing, 37

    • sorting, 660

  • observers, defined, 4

  • O(N log2N) sorts, 638657

  • order property, 557

  • order of growth, 4950

    • exponential time, 5354

    • linear time, 53

    • logarithmic time, 53

    • N log N time, 53

    • quadratic time, 53

  • @Override notation, 309310

P

  • package access, 5

  • packages, 5

    • with multiple compilation units, 20

    • subdirectories and, 21

    • syntax for, 1920

    • textbook program files, 2122

  • Palindrome class

  • palindromes

    • application, 244247

    • defined, 244

    • program, architecture for, 247

  • Parallelogram class, 75

  • parameters, 3738

  • parents, in trees, 31, 424

  • paths, between vertices, 586

  • pixels, defined, 186

  • pointers, references as, 34

  • polymorphism

    • defined, 18

    • inheritance based, 1819

    • interface-based, 7678

  • pop operation, 79, 80, 85, 127, 128

  • postconditions, defined, 72

  • postfix expressions

  • postorder traversal, 434, 452

    • code for, 455

    • defined, 433

    • generating, 433

    • uses for, 433

    • visualizing, 434

  • preconditions, defined, 71

  • preorder traversal, 434, 452

    • balancing binary search tree and, 471

    • code for, 455

    • defined, 433

    • generating, 433

    • uses for, 433, 435

    • visualizing, 434

  • primitive types, 27

    • reference types vs., 3435

  • primitive variables, 33

    • vs. nonprimitive, 309

    • vs. nonprimitive variables, 37

  • priority queues, 551-556

  • heaps used for implementing, 657

  • PriQueueInterface, 565

  • private access modifier, 5, 5t

  • professional testing, 9899

  • programming

    • concurrent, 279

    • dynamic, 200

  • protected access modifier, 5, 5t, 6

  • public access modifier, 5, 5t

  • push operation, 79, 80, 85, 124127, 127

Q

  • quadratic time, O(N2), 53

  • quadratice probing, 521523

    • hashing, in map ADT, 521523

    • vs. linear probing, 523

  • queue ADT, 2930, 29, 217283, 218220. See also priority queues

    • array-based implementation of, 223233

    • average waiting time application, 257268

    • circularly linked, 241

    • comparing implementations, 242244

    • description, 218219

    • interactive test driver, 234237

    • interface for, 220223

    • link-based implementations, 237244

    • operations on, 219

    • palindromes application, 244247

    • synchronized, 277282

    • variations, 247257

  • QueueInterface

    • code for, 221

    • in Java Library Collection Framework, 255

    • UML diagram of, 247

  • QueueOverflowException class, 221

  • QueueUnderflowException, 221, 241

  • quick sort algorithm, 647651

R

  • R-trees, 481

  • Random class, 260

  • RDN. See Relative Day Number

  • recPrintList method

    • the base-case question, 176

    • the general-case question, 176

    • the smaller-caller question, 176

  • recRemove method, 460, 464

    • recursive definition and code for, 464465

  • recRev-PrintList method

    • stacking and, 196

  • Rectangle class, 74, 78

  • recursion, 161201

  • array processing, 170-174

    • debugging recursive methods, 170

    • deciding whether to use recursive solution, 197201

    • depth of, 195

    • direct, 166

    • how it works, 191195

      • dynamic storage allocation, 193195

      • static storage allocation, 191193

    • indirect, 166

    • recursive algorithms, 163169

    • recursive definitions, 162163

    • recursive linked-list processing, 174182

    • stacking and, 196197

    • tail call elimination and, 195196

    • three questions approach, 167170

    • Towers of Hanoi, 182186

    • writing recursive methods, 169

  • reference types, primitive types vs., 3435

  • reference variables, 33

  • references, 3437

    • manipulating, exercising care in, 120

    • sorting and, 660

    • sorting arrays with, 660

  • rehashing, 525

  • reheapDown algorithm, 571

  • reheapDown method, 657

  • reheapDown operation

    • in action, 571

    • specification for, 559

  • reheapUp algorithm, 569

  • reheapUp method, code for, 569

  • reheapUp operation, 560

    • in action, 568

  • Relative Day Number, 7

  • remove operation, 460463, implementing Binary Search Tree ADT and

    • implementing, four methods for, 460462, 462

  • reserved words, in Java, 2

  • reusable software, 146

  • root

    • defined, 423

    • in trees, 31

  • root node

    • in binary trees, 432

    • reheapDown method and, 652, 653

  • run-time binding, 19

  • run-time (system) stack, defined, 194

  • Runnable interface, 271

  • RunTimeException class, 346

S

  • SafeDate class, 24, 25

  • Scanner class, 10

  • searching, 662665

    • high-probability ordering, 663

    • sequential, 663

  • selection sort

    • algorithm, 5053, 51

    • algorithm for, 627

    • analyzing, 630631

    • example of, 627

    • snapshot of algorithm, 628

    • test harness code, 628629

  • selectionSort method, 628, 630, 631, 638

    • code for, 629

    • order of magnitude for, 666t

  • self-organizing (or self-adjusting) lists, 664

  • self-referential class, defined, 113

  • sequential searches, 44, 663

  • set ADT, collection ADT, 333336

  • shape property, 557

  • short type, 27

  • shortBubble, 638

    • order of magnitude for, 666t

  • shortestPaths algorithm, 606-609

  • siblings, in trees, 424

  • simple sorts, 625638

  • Simulation class, 263

  • single-source shortest-paths problem, 605611

  • Smaller-Caller Question

    • binary search, 173

    • recursive algorithms verified with, 168

    • Towers of Hanoi and, 185

  • software, reusable, 146

  • sorted array based implementation

    • for collection ADT, 315324

    • for list ADT

      • LBList, 373

      • Like ABList, 373

      • SortedABList, 373

    • for map ADT, 507

    • priority queues and, 554555

  • sorted linked list

    • implementing priority queues and, 556

    • map implementations, 508

  • sorted lists, 30, 348, 373

  • SortedArrayCollection class, 317318

  • Sorting, 622625

    • algorithms, comparison of, 666t

    • arrays with references, 660

    • efficiency of, 622, 658660

      • eliminating calls to methods, 659

      • programmer time, 659660

      • space considerations, 660

      • when N is small, 658659

    • with heap, 655657

    • objects, 660

  • space considerations, 660

  • stable, 661662

  • Square class, 75

  • Stack class, 282

  • stack implementations, comparing, 131132

  • stack interface, 8490

    • example for, 8990

    • exceptional situations, 8588

  • stack operations

    • definitions of, 9396

    • efficiency of, 131

  • stack variations, 142145

  • stacking, recursive calls and, 196197

  • stack(s), 29, 29, 7881, 78

    • defined, 79

    • as last in, first out structures, 218

    • link-based, 121132

    • operations on, 79

    • usage of, 7981

  • static storage allocation, recursion and, 191193

  • storing information by reference, dangers of, 607

  • Selection sort, 625638

  • String class, 18, 19, 82, 124, 307

  • StringPairApp.java, code for, 513514

  • subclasses, 5

    • inheritance and, 12

  • subdirectories, packages and, 21

  • subtrees, 423

    • nodes without, determining, 446

    • right and left, 431

  • superclasses, 5

    • inheritance and, 12

  • SyncArrayBoundedQueue class, 282

  • SyncCounter class, code for, 276

  • synchronization, 275277, 283

  • synchronized keyword, 276, 279

  • synchronized queues, 277282

  • Synchronous-Queue, 282

  • system stack, defined, 194

T

  • T-square fractals, 187190

    • drawing stages, 187

    • variations Samples, 188

  • tail call elimination

    • recursive calls and, 195196

  • tail recursion

    • defined, 196

    • heap sort algorithm and, 655

  • test harness

    • code for Sorts.java, 623625

    • defined, 623

    • sorting and, 658

  • testing

  • thread object, instantiating, 272

  • threads

  • Three-Question approach

    • binary search, 173174

    • recursive algorithms verified with, 167170

    • recursive methods verified with, 170

  • time efficiency, measuring algorithm’s, 4445

  • toString method, 16, 17, 18, 19, 98

    • heap test and, 574575

    • invoking, 9

  • Towers of Hanoi, 182186

  • trailer node, 381

  • transformers, defined, 45

  • traveling salesman problem, exponential time and, 5354

  • traversals

  • traversing, linked list, 175178

  • tree shape, insertion order and, 468469, 468

  • tree traversals, 426429

    • breadth-first traversal, 426427

    • depth-first traversal, 428429

  • tree variations

    • application-specific variations, 479482

    • balanced search trees, 482485

  • trees, 31, 31, 423428, 431. See also binary search trees

    • See also binary trees

    • defined, 423

    • hierarchical relationships modeled with, 423

    • purpose of, 423

    • terminology, 425

    • unsorted array and, 653

  • tries/prefix trees, 481482

  • try-catch statement, 86

  • two-dimensional arrays, 39, 4243

    • variables, declaring, 43

U

  • UML. See Unified Modeling Language

  • unchecked exceptions, 27

  • undirected graphs, 584, 586, 587

  • Unified Modeling Language, class notation approach, 8

  • unreachable vertices, determining, 610611

  • unsupported operations, for list ADT

    • add or set, 375

    • sorted array-based list implementation, for list ADT, 373380

  • UnsupportedOperationException, 348, 375, 437

  • UseSafeDate class, 25

  • util package, 10

V

  • Vector class, 143, 282

  • vertex (vertices), 588

    • adjacency lists and, 596

    • adjacent, 586

    • finding index of, 595

    • in graphs, 31, 584

      • representing, 594

    • unreachable, 610611

  • vocabulary density, application, 305308

W

  • weighted graphs, defined, 587, 587

  • WeightedGraphInterface.java, code for, 590591

  • WeightedGraph.java, code for, 593594

  • well-formed expression algorithm, 103

  • Word Frequency Generator program, 472, 473

  • WordFreq class, 472473

  • WordFreq object, 473474, 501

  • worst case complexity, 4546

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.75.165