Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CMSC 3 1 5 Data Structures and Algorithms Programming Project 3 The third programming project involves writing a program to read in the preorder representation

CMSC 315 Data Structures and Algorithms
Programming Project 3
The third programming project involves writing a program to read in the preorder representation
of a binary tree and determine whether it is a balanced binary search tree. Given the binary tree
shown below:
Its preorder representation would be (53(28(11****)(41****)),(83(67****)**)). The
asterisks represent null children.
The program should repeatedly prompt the user for a binary tree. It should then display the tree
using indentation. For the above tree, its indented representation would be as follows:
53
28
11
41
83
67
It should then categorize the binary tree in one of three ways:
It is not a binary search tree
It is a balanced binary search tree
It is a binary search tree but it is not balanced
If the tree is not a balanced binary search tree, a binary search tree containing the same set of
values should be constructed and displayed in the indented format shown above. It is not
expected that the existing tree be rebalanced, just that a new tree with the same set of values be
constructed. Then the height of the original tree and the balanced binary search tree should be
displayed.
Shown below is a sample session that involves each of the above cases:
image text in transcribed

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

Step: 3

blur-text-image

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

How does the concept of hegemony relate to culture?

Answered: 1 week ago

Question

Differentiate between hard and soft measures of service quality.

Answered: 1 week ago

Question

Be familiar with the different perspectives of service quality.

Answered: 1 week ago