CS211 DATA STRUCTURES II

2ND COMPUTER SCIENCE & HIGHER DIPLOMA IN INFORMATION TECHNOLOGY

LABORATORY 3

Week Beginning 12/02/01

Mr. T Lysaght

 

BINARY SEARCH TREE

(You can download this BinarySearchTree.java file from the course homepage at:

http://www.cs.may.ie/~tlysaght/CS211/Cs211Lectures.html. Save the file to the same

directory as the TreeNode.java, TreeException.java and BinaryTreeBasis.java

class files.)

  1. Add the following methods to the class BinarySearchTree.java.
  1. Using the class BinarySearchTree insert construct a binary search tree with the following data:
  2. Integers: 40, 30, 55, 35, 20, 65, 58, 26, 50

  3. Delete the following items from the binary search tree:

 

  1. Empty the tree and reconstruct the original tree with the following values:
  2. Integers: 40, 30, 55, 35, 20, 65, 58, 26, 50

    Print the tree using inorder traversal, postorder traversal and preorder traversal.

     

     

     

  3. Add methods to the class BinarySearchTree which computes the height of a binary search tree.