Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ BinaryTree (.h and .cpp) Functional Requirements: A looping, menu-driven program that allows the user to create a binary tree and to display data about

C++ BinaryTree (.h and .cpp)

Functional Requirements: A looping, menu-driven program that allows the user to create a binary tree and to display data about the tree.

Programming Requirements:

Using the IntBinaryTree class from Chapter 21 as the starting point, add the following member functions:

Leaf Counter (which counts and returns the number of leaf nodes in the tree)

Tree Height (which counts and returns the height of the tree - the height is the number of levels it contains.

Tree Width (which counts and returns the width of the tree - the width is the largest number of nodes in the same level.)

Write a menu-driven program that will allow the user to:

1. Insert numbers

2. Display the tree (in order)

3. Display Leaf Count

4. Display Tree Height

5. Display Tree Width

6. Exit

Your program should contain high-level validation for numeric input (use a while loop and allow use to re-enter the data).

----------------

Test your program as follows:

Insert the following numbers (one at a time through menu option 1): 10, 87, 9, 55, 13, 40, 22,1,0,77, 0, 4, 55, 33, 22

Display the tree

Display the leaf count

Display the tree height

Display the tree width

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions