Question
C++ Programming (Please Help!) Checking point 2: Binary Tree 1. Write your own version of a class template that will create a binary tree that
C++ Programming (Please Help!)
Checking point 2: Binary Tree
1. Write your own version of a class template that will create a binary tree that can hold values of any data type.
Then add the following member functions to your defined class template.
2. Write a member function that counts and returns the number of nodes in the tree
3. Write a member function that counts and returns the number of leaf nodes in the tree.
4. Write a member function that returns the height of the tree. The height of the tree is the number of levels it contains. For example, the tree shown in the following figure has four levels
Figure 1.
5. Write a member function that returns the width of the tree. The width of the tree is the largest number of nodes in the same level. For example, the Figure 1, the width of the tree is 3.
6. Demonstrate the above member functions by your test program.
(C++ Programming)
8 10 1 6 14 4 7 (13
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