Google Interview Question
Software Engineer / Developersstart from the middle node...make that the root...call the same function for the left half array as well as the right half array
To be honest I did not understand the question...
But anyway, if the problem is what you thought it is, there is an assumption that the array is already sorted in order to apply your method.
I could not assume that the array was sorted...So I sorted the array and wrote the code as per the technique proposed by amit5624.. The interviewer completely ignored it and asked me to write code for a self balancing binary search tree instead..so i wrote the insert function for avl tree
- einstein010 April 18, 2011