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 Wed Jun 20 16:00:44 EEST 2007 - Powered by SVG-hut