Share
Explore BrainMass

C++ Binary Search Tree

Use the attached Binary Search Tree template (BST.h) for the following exercises.

1. Write a recursive member function level() for class template BST(Binary Search Tree) that determines the level in the BST at which a specified item is located. The root of the BST is at level 0, its children are at level 1, and so on.

2. Write a recursive member function leafCount() for class template BST to count the leaves in a binary tree.
[Hint: How is the number of leaves in the entire tree related to the number of leaves in the left and right subtrees of that root?]

Attachments

Solution Summary

Attached 220833.h also fixes some compilation errors in BST.h apart from adding new public functions (getLevel, getLeafCount) and new private functions (level, leafCount).

$2.19