Where do two paths part?
transcript
Two ids sit in a search tree. Where do their paths part? You do not need both paths. Think of two trails that join. The order tells you.
The ids are one and four. Start at eight. Eight, three, six and four are on the path to four. Eight, three and one are on the path to one. Both are smaller than eight. Go left. At three, one is smaller. Four is larger. The paths part. Three is the answer.
Now ids ten and fourteen. At eight, both are larger. Go right, to ten. Ten is one of the two ids. Stop.
Both ids smaller: go left. Both larger: go right. Otherwise stop. That node is the answer. It reads one path, not the tree. A chain of a hundred thousand is still one loop.
Go left, go right, or stop. The cost is the height, one path. Use loops, never deep recursion. Full breakdown in the lecture.