Thursday, December 20, 2012

Find Successor Of a Node

Book: Cracking the Coding Interview
Question: 4.6 (page 86)

Write an algorithm to find the 'next' node (i.e, in-order successor) of a given node in a binary search tree. You may assume that each node has a link to its parent.

Solution: Complexity - O(n) in the worst case. Did not test the below code; it makes sense and it should work fine.


No comments:

Post a Comment