DWG. 04 — BINARY SEARCH TREE
The same values, twice. On the left, built by taking the middle value as the root and repeating. On the right, built by inserting the values one at a time in sorted order — which is a linked list wearing a tree costume.
Search both at once and count the comparisons. That gap is the entire reason
isBalanced and rebalance exist.
balanced
0comparisons
degenerate
0comparisons
structure
Binary search tree
search, balanced
O(log n)
search, degenerate
O(n)
notes
Both trees hold identical values and both obey the search rule. Only the shape differs. Press rebalance to rebuild B from its own in-order traversal.