Google interview question

Write pseudo code for a Binary Search tree

Interview Answers

Anonymous

19 Oct 2010

I'm not going to write the code here but the function for a BST are: Insert Delete Find Traverse The only tricky part is the delete function where you are asked to delete a node which has both left and right children,you should swap the value of the node with the leftmost value of the right child and delete the leftmost right child (even if that child has a right child its not a big deal)

1

Anonymous

12 Dec 2010

Here is a good article with working code in Java and C++ and nice diagrams: http://www.algolist.net/Data_structures/Binary_search_tree/Internal_repr