Home CPSC 340

Binary Search Tree Exercise


To gain experience with binary search trees.


The tree balancing algorithm we saw in class creates a temporary array to store the nodes in. To do this, it must know how many nodes are in the tree. For the example in class, the tree kept a counter and incremented it on each insert and decremented it on each removal.

Instead, we can write a function that counts the number of nodes in the tree without needing to store it as a member variable. For this lab, you will write a function to do this.



When you're done, email the code to ifinlay@umw.edu.

Copyright © 2018 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.