Binary Search Tree: Adding a value to the tree

 

The goal for this exercise is to implement the binary search tree’s Add method, in C# source code, using recursion.

 

What you need to do for this exercise: 

  1. In the provided starter solution, there is a project named something like 03_PCE_StudentCode, there is a class named BinarySearchTreeFor this exercise, you should implement the ‘Add’ method, as described in the online lecture.
    1. This method MUST be implemented using Recursion.  You will get no points for a solution that does not use a recursive approach to solve this problem.
  2. Once you’ve completed the above tasks, you should test your code in order to make sure that it works.
    1. A good way to test your code would be to walk through your test code using the debugger.
    2. Another good way to test your insert routine would be to create a PrintTree routine, and have it print everything in your binary search tree, using an pre-order traversal.  This won’t give you a perfect picture of the structure of the tree, but it’s better than the normal in-order traversal (which prints out everything in order, regardless of the structure of the tree).
      We haven’t covered this yet, though, so you are NOT required to do this part of the exercise.