Build from the middle
transcript
An export gives seven ids, sorted. Insert them one by one. Each is larger than the last. What tree do you get?
Every id goes right. The tree is a chain. Seven levels. A search can take seven steps. With a hundred thousand ids, it is a hundred thousand.
Take the middle id, six, as the top. The left half is one, three, four. Its middle is three. The right half is eight, ten, fourteen. Its middle is ten. Do the same for each half. Three levels, not seven.
Take the middle id as the top. Build the left half the same way. Then build the right half. Each id is placed once. So n ids give about log n levels.
Sorted ids in order make a chain. Built from the middle, they make about log n levels. Each id is read at most once. Full breakdown in the lecture.