Foreword Page: 4 Preface Page: 5 Who This Book Is For Page: 5 About the Code Page: 5 Conventions Used in This Book Page: 6 O’Reilly Online Learning Page: 6 How to Contact Us Page: 6 Acknowledgments Page: 6 1. Problem Solving Page: 7 What Is an Algorithm? Page: 7 Finding the Largest Value in an Arbitrary List Page: 8 Counting Key Operations Page: 8 Models Can Predict Algorithm Performance Page: 8 Find Two Largest Values in an Arbitrary List Page: 10 Tournament Algorithm Page: 11 Time Complexity and Space Complexity Page: 13 Summary Page: 14 Challenge Exercises Page: 14 2. Analyzing Algorithms Page: 15 Using Empirical Models to Predict Performance Page: 15 Multiplication Can Be Faster Page: 16 Performance Classes Page: 16 Asymptotic Analysis Page: 17 Counting All Operations Page: 18 Counting All Bytes Page: 18 When One Door Closes, Another One Opens Page: 19 Binary Array Search Page: 19 Almost as Easy as π Page: 19 Two Birds with One Stone Page: 20 Pulling It All Together Page: 21 Curve Fitting Versus Lower and Upper Bounds Page: 22 Summary Page: 22 Challenge Exercises Page: 23 3. Better Living Through Better Hashing Page: 24 Associating Values with Keys Page: 24 Hash Functions and Hash Codes Page: 25 A Hashtable Structure for (Key, Value) Pairs Page: 26 Detecting and Resolving Collisions with Linear Probing Page: 26 Separate Chaining with Linked Lists Page: 28 Removing an Entry from a Linked List Page: 29 Evaluation Page: 30 Growing Hashtables Page: 31 Analyzing the Performance of Dynamic Hashtables Page: 32 Perfect Hashing Page: 33 Iterate Over (key, value) Pairs Page: 34 Summary Page: 34 Challenge Exercises Page: 35 4. Heaping It On Page: 37 Max Binary Heaps Page: 38 Inserting a (value, priority) Page: 39 Removing the Value with Highest Priority Page: 40 Representing a Binary Heap in an Array Page: 41 Implementation of Swim and Sink Page: 41 Summary Page: 42 Challenge Exercises Page: 42 5. Sorting Without a Hat Page: 44 Sorting by Swapping Page: 44 Selection Sort Page: 44 Anatomy of a Quadratic Sorting Algorithm Page: 45 Analyze Performance of Insertion Sort and Selection Sort Page: 45 Recursion and Divide and Conquer Page: 46 Merge Sort Page: 47 Quicksort Page: 48 Heap Sort Page: 49 Performance Comparison of O(N log N) Algorithms Page: 49 Tim Sort Page: 50 Summary Page: 51 Challenge Exercises Page: 51 6. Binary Trees: Infinity in the Palm of Your Hand Page: 52 Getting Started Page: 52 Binary Search Trees Page: 53 Searching for Values in a Binary Search Tree Page: 55 Removing Values from a Binary Search Tree Page: 55 Traversing a Binary Tree Page: 57 Analyzing Performance of Binary Search Trees Page: 57 Self-Balancing Binary Trees Page: 58 Analyzing Performance of Self-Balancing Trees Page: 60 Using Binary Tree as (key, value) Symbol Table Page: 60 Using the Binary Tree as a Priority Queue Page: 61 Summary Page: 62 Challenge Exercises Page: 62 7. Graphs: Only Connect! Page: 64 Graphs Efficiently Store Useful Information Page: 64 Using Depth First Search to Solve a Maze Page: 65 Breadth First Search Offers Different Searching Strategy Page: 67 Directed Graphs Page: 69 Graphs with Edge Weights Page: 72 Dijkstra’s Algorithm Page: 72 All-Pairs Shortest Path Page: 76 Floyd–Warshall Algorithm Page: 77 Summary Page: 78 Challenge Exercises Page: 79 8. Wrapping It Up Page: 80 Python Built-in Data Types Page: 80 Implementing Stack in Python Page: 81 Implementing Queues in Python Page: 81 Heap and Priority Queue Implementations Page: 82 Future Exploration Page: 82 Index Page: 84
Description: