To gain experience with binary search trees.
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.
count()which returns an integer giving the number of nodes in the tree. Remember this is most easily done recursively.
When you're done, email the code to firstname.lastname@example.org.
Copyright © 2019 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.