CS 302 - Data Structures

Spring 2015

Programming Assignment 6: Binary Search Tree

Due on Tuesday, Apr 14 at 9:00 am

Programming Problem 2 on Page 491. Remember that Chapter 16 provides details of how to implement binary search tree.

  1. Randomly generate 100 unique values in the range of [1-200] and insert them into a binary search tree (BST1). Print height and inorder output of the BST1 tree.
  2. Randomly generate 10 unique values in the range of [1-200] where there is an overlap with the previous values and insert them into another binary search tree (BST2). Print preorder, inorder, and postorder output of the BST2 tree.
  3. Find and remove any values of BST2 from BST1. Print height, number of nodes, and inorder output of the modified BST1 tree.
  4. Clear the binary search trees. Print whether trees are empty before and after clear operation.

Note: You can omit any operation that is not required for the above steps. If implemented up to 2 bonus points.


  1. Source code for your classes
  2. Doxygen reports for code documentation
  3. A main file that tests the classes with above steps.
  4. Test output of your codes.

Teaching Assistant: A. Soran

What to turn in: A softcopy of your sourcecode and reports should be uploaded to WebCT. Do not compress as a zip file or combine as a tar file.