Lemnisk Interview Question

Given an array representing insertion order in a BST, find the root-to-node path for any given node.

Interview Answers

Anonymous

Apr 4, 2014

1) Take to variables loverLimit and upperLimit 2) for each element in array 3) If element == node ; add element to path and return 4) If element is less than Node 5) if element is greater than than lower limit 6) add element to the path 7) update the lowerLimit = element 8) else move without doing anything

Anonymous

Jul 1, 2014

Would like to correct the above approach to also include the case where we update the upperLimit. If element is greater than Node if element is less that upperLimit update upperLimit else don't do anything