Problem Directory: /home/bvanderz/cs140/Labs/treeHeight

Problem Description

Write a recursive function to compute the height of a binary tree. The height of a binary tree can be recursively defined as follows:

height(root) = max(height(left subtree), height(right subtree)) + 1
height(NULL) = -1
The meaning of height(NULL) is -1 is that an empty tree has a height of -1. That means that a leaf, which has no children, will end up with a height of 0.


What To Do

  1. You will modify the file named treeHeight.cpp. Put your function definition where the comment tells you to do so.
  2. Compile your file into an executable named "treeHeight".
  3. There are three input files named input1.txt, input2.txt, and input3.txt. You can test your program by using these files as input to your program.
  4. There is an executable named "solution" that you can use to see the correct output. An example execution would be:
    	./solution < input1.txt
          
  5. You can run the "gradeall" script to see if your program passes the test cases.
  6. Get a TA to check you off when your function correctly passes the test cases.