Binary search tree
A binary tree where, at every node, everything on the left is smaller and everything on the right is larger. That way you search by discarding one side at each step.
Example
With root 8, left 3 and right 10, searching for 10 is 2 steps: 8, and since 10 is larger, go right.
Test yourself: Binary search tree
Binary search trees
In a binary search tree, a node's whole left subtree is ___ than it.
If the root is 8, its left can only hold values like 3, 1 or 6, and its right ones like 10 or 14.
Binary search trees
Searching a search tree, if the current node is smaller than what you want, you go ___.
What you want is larger, and larger values are on the right. Searching for 14 from a node 10, you go right.
Binary search trees
A binary search tree accepts duplicate values without any problem.
If 8 is already there and another 8 arrives, it's neither smaller nor larger: it breaks the rule. Usually it isn't inserted, or a counter is kept in the node.
0/3
â–¶ PlayLessons that use it
Hash tables
From key to slot in 1 calculation
Walking a tree
By levels or by branches
Binary search trees
Smaller on the left, larger on the right
AVL trees
A tree that straightens itself
Heaps
The smallest, always on top
Choosing how to search
Brute force or using the order
Divide and conquer
Split, solve and combine
