Home CPSC 340

Binary Search Tree Exercise

 

Objective

To gain experience with binary search trees.


 

Task

One method that we don't currently have in our binary search tree is one that tells us how many nodes we are storing. It might be helpful to know how many pieces of data our data structure contains.

One possible way of doing this is creating an integer that stores the number of elements, incrementing and decrementing it at the right times.

Instead however, you should write a method that counts the number of nodes in the tree without needing to store it as a member variable. This is most easily done using recursion.


 

Details


 

Submitting

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

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