Mark Allen Weiss,美國佛羅里達(dá)國際大學(xué)計(jì)算機(jī)學(xué)院教授,普林斯頓大學(xué)汁算機(jī)科學(xué)博士,他目前是AP(Advanced Placemenl)考試汁算機(jī)學(xué)科委員會(huì)的主席。除本書外,他還撰寫了Data Structures and Problem Solving Using Java(中文版第3版即將山人民郵電出版社出版)等著作。
圖書目錄
1 Introduction 1 1.1. What's the Book About? 1 1.2. A Brief Introduction to Recursion 3 Summary 7 Exercises 7 References 8
2 Algorithm Analysis 9 2.1. Mathematical Background 9 2.2. Model 12 2.3. What to Analyze 12 2.4. Running Time Calculations 14 2.4.1. A Simple Example 15 2.4.2. General Rules 15 2.4.3. Solutions for the Maximum Subsequence Sum Problem 18 2.4.4. Logarithms in the Running Time 22 2.4.5. Checking Your Analysis 27 2.4.6. A Grain of Salt 27 Summary 28 Exercises 29 References 33
3 Lists, Stacks, and Queues 35 3.1. Abstract Data Types (ADTs) 35 3.2. The List AnT 36 3.2.1. Simple Array Implementation of Lists 37 3.2.2. Linked Lists 37 3.2.3. Programming Details 38 3.2.4. Common Errors 43 3.2.5. Doubly Linked Lists 45 3.2.6. Circularly Linked Lists 46 3.2.7. Examples 46 3.2.8. Cursor Implementation of Linked Lists 50 3.3. The Stack ADT 56 3.3.1. Stack Model 56 3.3.2. Implementation of Stacks 57 3.3.3. Applications 65 3.4. The Queue AnT 73 3.4.1. Queue Model 73 3.4.2. Array Implementation of Queues 73 3.4.3. Applications of Queues 78 Summary 79 Exercises 79 4 Trees 83 4.1. Preliminaries 83 4.1.1. Terminology 83 4.1.2. Tree Traversals with an Application 84 4.2. Binary Trees 85 4.2.1. Implementation 86 4.2.2. Expression Trees 87 4.2.3. Tree Traversals 90 4.3. The Search Tree ADT Binary Search Trees 97 4.3.1. MakeEmpty 97 4.3.2. Find 97 4.3.3. FindMin and FindMax 99 4.3.4. Insert 100 4.3.5. Delete 101 4.3.6. Average-Case Analysis 103 4.4. AVL Trees 106 4.4.1. Single Rotation 108 4.4.2. Double Rotation 111 4.5. Splay Trees 119 4.5.1. A Simple Idea (That Does Not Work) 12 0 4.5.2. Splaying 12 2 4.6. B-Trees 128 Summary 133 Exercises 134 References 141 5 Priority Queues (Heaps) 145 5.1. Model 145 5.2. Simple Implementations 146 5.3. Binary Heap 147 5.3.1. Structure Property 147 5.3.2. Heap Order Property 148 5.3.3. Basic Heap Operations 150 5.3.4. Other Heap Operations 154 5.4. Applications of Priority Queues 157 5.4.1. The Selection Problem 157 5.4.2. Event Simulation 159 5.5. d-Heaps 160 5.6. Leftist Heaps 161 5.6.1. Leftist Heap Property 161 5.6.2. Leftist Heap Operations 162 5.7. Skew Heaps 168 5.8. Binomial Queues 170 5.8.1. Binomial Queue Structure 170 5.8.2. Binomial Queue Operations 172 5.8.3. Implementation of Binomial Queues 173 Summary 180 Exercises 180 References 184 6 Sorting 187 6.1. Preliminaries 187 6.2. Insertion Sort 188 6.2.1. The Algorithm 188 6.2.2. Analysis of Insertion Sort 189 6.3. A Lower Bound for Simple Sorting Algorithms 189 6.4. Shellsort 190 6.4.1. Worst-Case Analysis of Shellsort 192 6.5. Heapsort 194 6.5.1. Analysis of Heapsort 196 6.6. Mergesort 198 6.6.1. Analysis of Mergesort 200 6.7. Quicksort 203 6.7.1. Picking the Pivot 204 6.7.2. Partitioning Strategy 205 6.7.3. Small Arrays 20 8 6.7.4. Actual Quicksort Routines 208 6.7.5. Analysis of Quicksort 209 6.7.6. A Linear-Expected-Time Algorithm for Selection 213 6.8. Sorting Large Structures 215 6.9. A General Lower Bound for Sorting 216 6.9.1. Decision Trees 217 6.10. Bucket Sort and Radix Sort 219 6.11. External Sorting 222 6.11.1. Why We Need New Algorithms 222 6.11.2. Model for External Sorting 222 6.11.3. The Simple Algorithm 222 6.11.4. Multiway Merge 224 6.11.5. Polyphase Merge 225 6.11.6. Replacement Selection 226 Summary 227 Exercises 229 7 Hashing 235 7.1. General Idea 235 7.2. Hash Function 237 7.3. Separate Chaining 239 7.4. Open Addressing 244 7.4.1. Linear Probing 244 7.4.2. Quadratic Probing 247 7.4.3. Double Hashing 251 7.5. Rehashing 252 7.6. Extendible Hashing 255 Summary 258 Exercises 259 References 262
8 The Disjoint Set AnT 265 8.1. Equivalence Relations 265 8.2. The Dynamic Equivalence Problem 266 8.3. Basic Data Structure 267 8.4. Smart Union Algorithms 271 8.5. Path Compression 273 8.6. Worst Case for Union-by-Rank and Path Compression 275 8.6.1. Analysis of the Union/Find Algorithm 275 8.7. An Application 281 Summary 281 Exercises 282 References 283