Binary Search Tree Search

Hide text Hide pseudo-code

Search the given key from both of the binary search trees. The key can be searched by selecting in each step the correct minimized tree where the search proceeds.

Some additional problems.

Search(Node root, Key k)
1 if (root == null) //failed search
2   return null;
3 if (k == root.key) //succesfull search
4   return root;
5 if (k < root.key) //k in left branch
6   return Search(root.left, k);
7 else //k > root.key, i.e. k in right branch
8   return Search(root.right, k);


  Created Fri Oct 30 13:52:50 EET 2009 - Powered by SVG-hut