Binary Search Tree Insertion

Hide text Hide pseudo-code

Insert the given keys into the initially empty binary search tree.

Some additional problems.

Insert(Node root, Key k)
1 if (root == null) // insertion position found
2   return new Node(k);
3 if (k <= root.key) // proceed to the left branch
4   root.left = Insert(root.left, k);
5 else // k > root.key, i.e. proceed to the right branch
6   root.right = Insert(root.right, k);


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