Tree
A structure that organizes elements in levels, from top to bottom: each element has a single parent and can have several children.
Example
An org chart: the director on top, 4 managers below and 10 employees under each manager. Each employee has just 1 boss.
Lessons that use it
What system design is
Think before you build
Storage types
Where data lives
What is an algorithm
You already use algorithms
Iteration and recursion
2 ways to repeat
Types of structures
How they relate and where they live
Basic data types
The bricks of everything
Stacks
Last in, first out
Hash collisions
When 2 keys want the same spot
Binary trees
Each node, at most 2 children
Walking a tree
By levels or by branches
Trees in an array
No references, just math
Binary search trees
Smaller on the left, larger on the right
AVL trees
A tree that straightens itself
Heaps
The smallest, always on top
Graphs
Points and connections
Walking a graph
BFS and DFS, now with cycles
Choosing how to search
Brute force or using the order
Bucket sort
Split into buckets and sort each one
Divide and conquer
Split, solve and combine
Rebuilding a tree
Root, left and right
Backtracking
Try, and if it fails, go back
Permutations
Every possible order
N-queens
None attacks another
Solving with DP
State, transition and borders
0-1 knapsack
Take it or leave it
Replication
Copies of the database
Quadtrees
Splitting the map in 4
Designing Twitter
1 billion tweets a day
Designing Uber
10 million rides a day
