Absolute beginner's guide to algorithms : a practical introduction to data structures and algorithms in JavaScript
With the explosive growth in the amount of data and the diversity of computing applications, efficient algorithms are needed now more than ever. Programming languages come and go, but the core of programming--algorithms and data structures--remains the same. Absolute Beginner's Guide to Algorithms is the fastest way to learn algorithms and data structures. Using helpful diagrams and fully annotated code samples in Javascript, you will start with the basics and gradually go deeper and broader into all the techniques you need to organize your data. Start fast with data structures basics: arrays, stacks, queues, trees, heaps, and more. Walk through popular search, sort, and graph algorithms. Understand Big-O notation and why some algorithms are fast and why others are slow. Balance theory with practice by playing with the fully functional JavaScript implementations of all covered data structures and algorithms
Available Copies by Location
Location | |
---|---|
Community Centre | Available |
Browse Related Items
- ISBN: 9780138222291 (pbk.)
- Physical Description xv, 394 pages : illustrations ; 24 cm.
Content descriptions
General Note: | Includes index. |
Series
Additional Information
Table of Contents
Absolute Beginner's Guide to Algorithms : A Practical Introduction to Data Structures and Algorithms in JavaScript
Section | Section Description | Page Number |
---|---|---|
I | Data Structures | |
1 | Introduction to Data Structures | 1 |
Right Tool for the Right Job | 2 | |
Back to Data Structures | 5 | |
Conclusion | 6 | |
Some Additional Resources | 6 | |
2 | Big-O Notation and Complexity Analysis | 7 |
It's Example Time | 8 | |
It's Big-O Notation Time! | 11 | |
Conclusion | 15 | |
Some Additional Resources | 15 | |
3 | Arrays | 17 |
What Is an Array? | 18 | |
Adding an Item | 19 | |
Deleting an Item | 21 | |
Searching for an Item | 22 | |
Accessing an Item | 24 | |
Array Implementation / Use Cases | 24 | |
Arrays and Memory | 26 | |
Performance Considerations | 30 | |
Access | 31 | |
Insertion | 31 | |
Deletion | 32 | |
Searching | 32 | |
Conclusion | 32 | |
Some Additional Resources | 33 | |
4 | Linked Lists | 35 |
Meet the Linked List | 36 | |
Finding a Value | 36 | |
Adding Nodes | 38 | |
Deleting a Node | 39 | |
Linked List: Time and Space Complexity | 40 | |
Deeper Look at the Running Time | 41 | |
Space Complexity | 41 | |
Linked List Variations | 41 | |
Singly Linked List | 42 | |
Doubly Linked List | 42 | |
Circular Linked List | 42 | |
Skip List | 44 | |
Implementation | 44 | |
Conclusion | 52 | |
Some Additional Resources | 52 | |
5 | Stacks | 53 |
Meet the Stack | 54 | |
A JavaScript Implementation | 56 | |
Stacks: Time and Space Complexity | 58 | |
Runtime Performance | 59 | |
Memory Performance | 59 | |
Conclusion | 59 | |
Some Additional Resources | 60 | |
6 | Queues | 61 |
Meet the Queue | 62 | |
A JavaScript Implementation | 64 | |
Queues: Time and Space Complexity | 66 | |
Runtime Performance | 66 | |
Memory Performance | 67 | |
Conclusion | 67 | |
Some Additional Resources | 68 | |
7 | Trees | 69 |
Trees 101 | 70 | |
Height and Depth | 75 | |
Conclusion | 77 | |
Some Additional Resources | 77 | |
8 | Binary Trees | 79 |
Meet the Binary Tree | 80 | |
Rules Explained | 80 | |
Binary Tree Variants | 82 | |
What about Adding, Removing, and Finding Nodes? | 86 | |
A Simple Binary Tree Implementation | 86 | |
Conclusion | 89 | |
Some Additional Resources | 89 | |
9 | Binary Search Trees | 91 |
It's Just a Data Structure | 93 | |
Adding Nodes | 93 | |
Removing Nodes | 97 | |
Implementing a Binary Search Tree | 103 | |
Performance and Memory Characteristics | 110 | |
Conclusion | 112 | |
Some Additional Resources | 112 | |
10 | Heaps | 113 |
Meet the Heap | 114 | |
Common Heap Operations | 116 | |
Heap Implementation | 126 | |
Heaps as Arrays | 127 | |
The Code | 128 | |
Performance Characteristics | 132 | |
Removing the Root Node | 132 | |
Inserting an Item | 133 | |
Performance Summary | 134 | |
Conclusion | 134 | |
Some Additional Resources | 135 | |
11 | Hashtable (aka Hashmap or Dictionary) | 137 |
A Very Efficient Robot | 138 | |
From Robots to Hashing Functions | 142 | |
From Hashing Functions to Hashtables | 145 | |
Adding Items to Our Hashtable | 146 | |
Reading Items from Our Hashtable | 147 | |
JavaScript Implementation/Usage | 148 | |
Dealing with Collisions | 150 | |
Performance and Memory | 151 | |
Conclusion | 153 | |
Some Additional Resources | 154 | |
12 | Trie (aka Prefix Tree) | 155 |
What is a Trie? | 156 | |
Inserting Words | 157 | |
Finding Items | 162 | |
Deleting Items | 165 | |
Diving Deeper into Tries | 167 | |
Many More Examples Abound! | 172 | |
Implementation Time | 173 | |
Performance | 179 | |
Conclusion | 181 | |
Some Additional Resources | 181 | |
13 | Graphs | 183 |
What Is a Graph? | 184 | |
Graph Implementation | 190 | |
Representing Nodes | 190 | |
The Code | 192 | |
Conclusion | 196 | |
Some Additional Resources | 197 | |
II | Algorithms | |
14 | Introduction to Recursion | 199 |
Our Giant Cookie Problem | 200 | |
Recursive function call | 202 | |
Recursive Function Call | 202 | |
Terminating condition | 203 | |
Conclusion | 206 | |
Some Additional Resources | 206 | |
15 | Fibonacci and Going Beyond Recursion | 207 |
Recursively Solving the Fibonacci Sequence | 209 | |
Recursion with Memoization | 213 | |
Taking an Iteration-Based Approach | 215 | |
Going Deeper on the Speed | 217 | |
Conclusion | 218 | |
Some Additional Resources | 219 | |
16 | Towers of Hanoi | 221 |
How Towers of Hanoi is Played | 222 | |
The Single Disk Case | 223 | |
It's Two Disk Time | 224 | |
Three Disks | 225 | |
The Algorithm | 228 | |
The Code Solution | 229 | |
Check Out the Recursiveness! | 231 | |
It's Math Time | 232 | |
Conclusion | 234 | |
Some Additional Resources | 234 | |
17 | Search Algorithms and Linear Search | 235 |
Linear Search | 236 | |
Linear Search at Work | 236 | |
JavaScript Implementation | 238 | |
Runtime Characteristics | 239 | |
Conclusion | 241 | |
Some Additional Resources | 241 | |
18 | Faster Searching with Binary Search | 243 |
Binary Search in Action | 244 | |
Sorted Items Only, Please | 244 | |
Dealing with the Middle Element | 245 | |
Dividing FTW! | 247 | |
The JavaScript Implementation | 250 | |
Iterative Approach | 250 | |
Recursive Approach | 251 | |
Example of the Code at Work | 252 | |
Runtime Performance | 254 | |
Conclusion | 257 | |
Some Additional Resources | 257 | |
19 | Binary Tree Traversal | 259 |
Breadth-First Traversal | 260 | |
Depth-First Traversal | 265 | |
Implementing Our Traversal Approaches | 270 | |
Node Exploration in the Breadth-First Approach | 270 | |
Node Exploration in the Depth-First Approach | 272 | |
Looking at the Code | 273 | |
Performance of Our Traversal Approaches | 278 | |
Conclusion | 279 | |
Some Additional Resources | 279 | |
20 | Depth-First Search (DFS) and Breadth-First Search (BFS) | 281 |
A Tale of Two Exploration Approaches | 282 | |
Depth-First Search Overview | 283 | |
Breadth-First Search Overview | 284 | |
Yes, They Are Different! | 284 | |
It's Example Time | 285 | |
Exploring with DFS | 285 | |
Exploring with BFS | 293 | |
When to Use DFS? When to Use BFS? | 298 | |
A Javascript Implementation | 300 | |
Using the Code | 305 | |
Implementation Detail | 306 | |
Performance Details | 307 | |
Conclusion | 308 | |
Some Additional Resources | 308 | |
21 | Quicksort | 309 |
A Look at How Quicksort Works | 310 | |
A Simple Look | 310 | |
Another Simple Look | 314 | |
It's Implementation Time | 319 | |
Performance Characteristics | 322 | |
Time Complexity | 323 | |
Space Complexity | 323 | |
Stability | 323 | |
Conclusion | 323 | |
Some Additional Resources | 324 | |
22 | Bubblesort | 325 |
How Bubblesort Works | 326 | |
Walkthrough | 329 | |
The Code | 333 | |
Conclusion | 333 | |
Some Additional Resources | 334 | |
23 | Insertion Sort | 335 |
How Insertion Sort Works | 336 | |
One More Example | 347 | |
Algorithm Overview and Implementation | 349 | |
Performance Analysis | 351 | |
Conclusion | 353 | |
Some Additional Resources | 353 | |
24 | Selection Sort | 355 |
Selection Sort Walkthrough | 356 | |
Algorithm Deep Dive | 364 | |
The JavaScript Implementation | 366 | |
Conclusion | 369 | |
Some Additional Resources | 369 | |
25 | Mergesort | 371 |
How Mergesort Works | 372 | |
Mergesort: The Algorithm Details | 379 | |
Looking at the Code | 380 | |
Conclusion | 381 | |
Some Additional Resources | 382 | |
26 | Conclusion | 383 |
Index | 387 |