Q. Give a node n of a BST, with left, right and parent pointers accessible, you have to find the next successor of this node in a BST (successor as in when node values are sorted in ascending order, the one after value of n)
A. 2 cases
- Right child exists: Left most node in right child subtree
- Right child does not exist: Keep following parent pointer until n lies in the left subtree of parent pointer (which implies that parent is bigger and hence is the next successor)