TwiddleLab / Courses / Code
Data Structures You Can See
Stacks, queues, hash tables and trees you can poke, then pick the right one for the job.
Best after: Build with Python, Algorithms in Motion
Lessons
- Stacks: Last In, First Out (5 min): A stack keeps things in a pile: you add to the top and take from the top.
- Queues: First In, First Out (7 min): A queue is a line: items join at the back and leave from the front.
- Linked Lists: Chains of Arrows (7 min): Putting an item at the front of a Python list shifts every other item: n moves for n items.
- Hash Tables: How Dictionaries Find Things (7 min): A hash function turns a key into a number. The number % the table size picks a locker.
- Sets: Is It In There? (7 min): A set holds each item once, in no particular order. It's a hash table with keys and no values.
- Trees: Folders Inside Folders (7 min): A tree has one root; every other node has one parent and any number of children. Nodes with no children are leaves.
- Binary Search Trees (7 min): A binary search tree keeps one rule at every node: smaller values in the left branch, bigger in the right.
- Heaps and Priority Queues (7 min): A priority queue hands out the most urgent item first, not the oldest.
- Choosing the Right Structure (7 min): No structure is best at everything. Each is fast at some jobs and slow at others: a trade-off.
- Undo Button and Leaderboard (7 min): Undo and Redo run on two stacks: Undo moves the newest action from done to undone, Redo moves it back.
Lessons are interactive and need JavaScript. Turn it on to play them.