Question
Could someone please help me with this Binary Tree assignment in C++. Thank you! Write your own version of a class template that will create
Could someone please help me with this Binary Tree assignment in C++. Thank you!
Write your own version of a class template that will create a binary tree that can hold values of any data type. Demonstrate the class with a driver program. Place your binary tree template in it's own header file, Btree.h. Include methods for the following:
1. inserting new values into the tree
2. removing nodes from the tree
3. searching the tree
4. returning the number of nodes in the tree
5. displaying the contents of the tree using preorder traversal
Your public interface must include at least the following methods (Where T is a generic parameter ( you can name it anything):
- void insert( T ) - void remove( T ) - bool search( T ) - void preprint() - int count()
Sample Usage: BTree
A sample run:
Could be anything that demonstrates the class. A menu-driven program would be great for this.
Perhaps include options for insert, remove, search, count, print operations: (I)nsert (R)emove (S)earch (C)ount (P)rint (Q)uit
And here is the incomplete BTree.h
#ifndef #define
#include
template
private: // define and declare the BTree node here // recursive method prototypes void preprint( Node* ) const; };
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started