
| preface 1 introduction to data structures 1-1 what is this book about? 2 data structures and algorithms 5 1-2 abstract view of data structures 5 the time 24 adt 6 1-3 an adt as a class 8 the c++ class 8 private and public sections 9 encapsulation and information hiding 9 the time 24 class 9 1-4 implementing c++ classes 13 implementation of the time 24 class 14 1-5 declaring and using objects 18 running a program 18 1-6 implementing a class with inline code 21 compiler use of inline code 22 1-7 application programming interface(api) 23 random numbers 24 the random number api 24 .application: the game of craps 26 1-8 strings 28 the string class 30 additional string functions and operations 31 chapter summary 36 classes and libraries in the chapter 37 review exercises 38 answers to review exercises 40 written exercises 42 programming exercises 48 programming projects 51 2 object design techniques 2-1 software design 55 request and problem analysis 56 program design 57 designing the calendar class 58 program implementation 62 implementing the calendar class 62 program testing and debugging 64 program maintenance 68 2-2 handling runtime errors 68 terminate program 69 set a flag 69 c++ exceptions 70 2-3 object composition 74 the timecard class 75 implementing the timecard class 77 2-4 operator overloading 82 operator functions s5 operator overloading with free functions 86 operator overloading with friend functions 87 overloading stream i/o operators 89 member function overloading 94 chapter summary 97 classes and libraries in the chapter 98 review exercises 99 answers to review exercises 100 written exercises 102 programming exercises 107 programming projects 108 3 introduction to algorithms 3-1 selection sort 115 selection sort algorithm 116 3-2 simple search algorithms 120 sequential search 120 binary search 122 3-3 analysis of algorithms 127 system/memory performance criteria 128 algorithm performance criteria: running time analysis 128 big-o notation 131 common orders of magnitude 133 3-4 analyzing the search algorithms 135 binary search running time 135 comparing search algorithms 136 3-5 making algorithms generic 139 template syntax 140 runtime template expansion 142 template-based searching functions 144 3-6 the concept of recursion 146 implementing recursive functions 148 how recursion works 149 application: multibase output 152 3-7 problem solving with recursion 155 tower of hanoi 155 number theory; the greatest common divisor 159 application of gcd - rational numbers 161 evaluating recursion 164 chapter summary 168 classes and libraries in the chapter 169 review exercises 169 answers to review exercises 172 written exercises 173 programming exercises 179 programming project 182 4 the vector container 4-1 overview of stl container classes 184 4-2 template classes 188 constructing a template class 188 declaring template class objects 191 4-3 the vector class 192 introducing the vector container 195 the vector api 200 4-4 vector applications 202 joining vectors 203 the insertion sort 203 chapter summary 208 classes and libraries in the chapter 209 review exercises 209 answers to review, exercises 211 written exercises 211 programming exercises 216 programming project 217 5 pointers and dynamic memory 5-1 c++ pointers 221 declaring pointer variables 222 assigning values to pointers 222 accessing data with pointers 224 arrays and pointers 225 pointers and class types 227 5-2 dynamic memory 229 the memory allocation operator new 229 dynamic array allocation 231 the memory deallocation operator delete 232 5-3 classes using dynamic memory 234 the class dynamicclass 234 the destructor 236 5-4 assignment and initialization 240 assignment issues 240 overloading the assignment operator 242 the pointer this 243 initialization issues 243 creating a copy constructor 244 5-5 the minivector class 247 design of the minivector class 248 reserving more capacity 251 the minivector constructor, destructor, and assignment 253 adding and removing elements from a minivector object 254 overloading the index operator 258 5-6 the matrix class 260 describing the matrix container 261 implementing matrix functions 265 chapter summary 266 classes and libraries in the chapter 267 review exercises 268 answers to review, exercises 270 written exercises 271 programming exercises 277 programming project 279 6 the list container and iterators 6-1 the list container 282 the list adt 2s4 the list api 286 application:a list palindrome 288 6-2 iterators 290 the iterator concept 290 constant iterators 294 the sequential search of a list 296 application: word frequencies 298 6-3 general list insert and erase operations 302 ordered lists 305 removing duplicates 307 splicing two lists 309 6-4 case study: graduation lists 310 problem analysis 310 program design 310 program implementation 312 chapter summary 315 classes and libraries in the chapter 316 review exercises 316 answers to review exercises 318 written exercises 319 programming exercises 322 programming project 325 7 stacks 7-1 the stack adt 328 multibase output 332 uncoupling stack elements 336 7-2 recursive code and the runtime stack 339 7-3 stack implementation 342 ministack class implementation 345 implementation of the stl stack class (optional) 346 7-4 postfix expressions 347 postfix evaluation 349 the postfixeval class 350 7-5 case study: infix expression evaluation 357 infix expression .attributes 358 infix to postfix conversion:algorithm design 359 infix to postfix conversion: object design 364 infix2postfix class implementation 366 chapter summary 372 classes in the chapter 373 review exercises 373 answers to review exercises 375 written exercises 377 prooramming exercises 381 programming projects 382 8 queues and priority queues 8-1 the queue adt 386 application: scheduling queue 388 8-2 the radix sort 390 radix sort algorithm 391 8-3 implementing the miniqueue class 395 implementation of the stl queue class (optional) 398 8-4 case study: time-driven simulation 399 simulation design 400 simulation implementation 401 8-5 array-based queue implementation 406 designing the bounded queue 409 implementing the bounded queue 411 8-6 priority queues 412 priority queue adt 413 sorting with a priority queue 415 company support services 417 chapter summary 421 classes and libraries in the chapter 422 review exercises 423 answers to review exercises 425 written exercises 426 programming exercises 430 programming project 432 9 linked lists 9-1 linked list nodes 438 the node class 439 adding and removing nodes 442 9-2 building liniced lists 443 defining a singly linked list 443 inserting at the front of a linked list 445 erasing at the front of a linked list 447 removing a target node 44s 9-3 handling the back of the list 452 designing a new linked list structure 453 9-4 implementing a linked queue 455 the linkedqueue class 456 implementing the linkedqueue class 457 9-5 doubly linked lists 462 dnode objects 463 circular doubly linked lists 466 9-6 updating a doubly linked list 468 the insert() function 468 the erase() function 470 9-7 the josephus problem 474 9-8 the minilist class 477 minilist class private members 478 minilist class constructors and destructor 479 functions dealing with the ends of a list 480 minilist iterators 481 the minilist member functions begin() and end() 485 the general list insert function 485 9-9 selecting a seouence container 486 chapter summary 487 classes and libraries in the chapter 489 review exercises 489 answers to review exercises 493 written exercises 495 programming exercises 498 programming project 500 10 binary trees 10-1 tree structures 504 tree terminology 505 binary trees 506 10-2 binary tree nodes 510 building a binary tree 511 10-3 binary tree scan algorithms 514 recursive tree traversals 514 iterative level-order scan 518 10-4 using tree scan algorithms 522 computing the leaf count 522 computing the depths of a tree 523 copying a binary tree 526 deleting tree nodes. 529 displaying a binary tree. 530 10-5 binary search trees 532 |
商品评论(0条)