The longest path can miss the root
transcript
Find the longest path in a tree. Start at the root. Add its two heights. That is not always right. The longest path can miss the root. Watch a tree where it does.
This tree has the root ninety. Its left side is four levels deep. Its right side is empty. Four plus zero gives four links. But twenty to eighty five has five links. It turns at fifty, below the root.
Look at node fifty. Its left side is two levels deep. Its right side is three levels deep. The best path that turns here has five links. But fifty returns only four to its parent.
Treat every node as a possible turn. The best path there is left height plus right height. Keep the largest. Return only one plus the taller side.
A longest path turns at one node. That node can be anywhere. Check every node. Full breakdown in the lecture.