# Binary Tree Template Write your own version of a class template that will create a binary...

###### Question:

Binary Tree Template

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:

inserting new values into the tree

removing nodes from the tree

searching the tree

returning the number of nodes in the tree

displaying the contents of the tree using preorder traversal

Your public interface must include at least the following methods:

-- void insert( T )
-- void remove( T )
-- bool search( T )
-- void preprint()
-- int count()

Where T is a generic parameter ( you can name it anything, I just chose T )

Sample Usage:

BTree b;

b.preprint();
cout << b.count();
b.insert('A');
cout << b.search('A');
b.remove('A');

Should be able to write statements like this in a program and have your class compile and run.
The count method must use recursion, you may not store the number of nodes as an attribute within the class.
You may not use a container from the STL.

I've attached an incomplete BTree.h header file to get you started.

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

In C++ pls

// complete these pre-processor directives

ifndef

define

include <iostream>

using std::cout;

using std::endl;

template <class T>

class BTree

{

public:

// constructor

// destructor

// public interface prototypes

void insert( T );

void remove( T );

void preprint() const;

bool search( T value ) const

int count() const

private:

// define and declare the BTree node here

// recursive method prototypes

void preprint( Node* ) const;

};

// method definitions here

template< class T >

void BTree<T>::preprint( Node* r ) const

{

}

endif

#### Similar Solved Questions

##### Chapter 16, Problem 16.064 xIncorrect. Determine Vo in the circuit in the figure below. 2 1...
Chapter 16, Problem 16.064 xIncorrect. Determine Vo in the circuit in the figure below. 2 1 2 j2? 2/0 A 2? Enter (a) the amplitude and (b) the phase angle. The phase angle must be in the interval (-180°, 180°] (a) T3.47 (b) TT-23 degrees...
##### Please also include formulas used 2. Two positive charges are located a distance of 0.58 m...
Please also include formulas used 2. Two positive charges are located a distance of 0.58 m apart on the x axis. At the origin, the charge is 5.5 x 104c, and at x-0.58m the charge is 3.3 x 10-c. At what point is the electric field equal to zero...
##### 31
In a certain region the average horizontal component of Earth'smagnetic field is 22 μT, and the average inclination or "dip" is74°. What is the correspondingmagnitude of Earth's magneticfield in microteslas?NumberUnitsμTT·mT/sJ/TµWbWb/m...
##### "Why are more American women dying after childbirth?" Watch video by PBS News Hour "Why are...
"Why are more American women dying after childbirth?" Watch video by PBS News Hour "Why are more American women dying after childbirth?" at https://www.youtube.com/watch?v=K4AzpCITbhE&t=69s Question: 1. Based on the reports from the video, what is/are the reasons rise of maternal...
##### Mark Sexton and Todd Story have been discussing the future of S&S Air. The company has...
Mark Sexton and Todd Story have been discussing the future of S&S Air. The company has been experiencing fast growth, and the two see only clear skies in the company’s future. However, the fast growth can no longer be funded by internal sources, so Mark and Todd have decided the time is ri...
##### 10. According to the first law of thermodynamics, the energy of the universe is constant. Does...
10. According to the first law of thermodynamics, the energy of the universe is constant. Does this mean that AE is always equal to zero? a. Yes, AE = 0 at all times, which is why 9 = -W. b. No, AE does not always equal zero, but this is only due to factors like friction and heat. c. NO, AE does not...
##### 09, Problem X1 perpendicular to the arm, as the figure indicates The forearm weighs 18 0...
09, Problem X1 perpendicular to the arm, as the figure indicates The forearm weighs 18 0 N and has a center of grevity s indicated. The sale registers 126 & Determne the ntuae of Jl...
##### Case Study 2 unthinkable tragedy
Case Study No. 2: A young man enters pilot training and needs to take a leave of absence of owing to mental health issues, which he describes as “burnout”. Following therapy, he is allowed to return to his studies and completes the course. After graduation he applies for a position with ...
##### The separate condensed balance sheets of Patrick Corporation and its wholly-owned subsidiary, Sean Corporation, are as...
The separate condensed balance sheets of Patrick Corporation and its wholly-owned subsidiary, Sean Corporation, are as follows: BALANCE SHEETS December 31, 2020 Patrick Sean Cash $78,000$ 66,000 Accounts receivable (net) 130,000 38,000 Inventories 88,000 72,000 Plant and equipm...
##### Can you help me with this problem, since I don't know which charges I have to...
can you help me with this problem, since I don't know which charges I have to consider in summing the different contributes of the energy. thanks Question Hydrogen bonding is responsible for many of the unusual properties of water. A simplified A model represents a hydrogen bond as the electros...
##### Consider a plain vanilla fixed for floating interest rate swap with a notional principal of 4,100,000...
Consider a plain vanilla fixed for floating interest rate swap with a notional principal of 4,100,000 and annual payments. Initially the swap was supposed to last for five years and now three years remain. If the initial fixed rate is 0.09, LIBOR is 0.08, and the year three payment was just made (tw...
##### How did the Tet offensive add to the "so-called" credibility gap?
How did the Tet offensive add to the "so-called" credibility gap?...
##### COX Limited is a multinational telecommunications company owned by a Canadian businesswoman. It has numerous long-term...
COX Limited is a multinational telecommunications company owned by a Canadian businesswoman. It has numerous long-term investments in a wide variety of equity instruments. Some investments have to be measured at fair value at each reporting date. In turn, the unrealized gains will be reported in eit...
##### How do you convert (x + 1)^2 + (y + 1)^2 =4 into polar form?
How do you convert (x + 1)^2 + (y + 1)^2 =4 into polar form?...