Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A. Write a function named genData that given an integer n, generates a list of n random integers in the interval [-n, n] (square bracket

A. Write a function named genData that given an integer n, generates a list of n random integers in the interval [-n, n] (square bracket means inclusive). B. Write a function named makeBST that given a list of data, generates a binary search tree. C. Write a function named printBT() that given a binary tree, prints the trees elements using an in-order traversal. D. Write a function named height() that finds the height of the binary tree which has been passed as its parameter.

This is a practice on design, implement and analyzing problems using binary search trees. The main function of your test program (testBST.cpp) should be compatible with the following main function. By compatible it means the number of parameters of each function should match. The type of parameters is determined by your design and implementation. This makes some constraints in your design, which is likely to occur in the real world.

int main() { // declaration of your variables ... n1 = getInput(); // either generates a random non-negative // integer or reads it from input list1 = genData(n1); //generates a list of n1 random numbers [-n1, n1] cout << "The List1: "; printList(list1); //prints elements of the given list n2 = getInput(); list2 = genData(n2); //generates a list of n2 random numbers [-n2, n2] printList(list2); bst1 = makeBST(list1); cout << "In-order traversal of bst1 is: "; printBT(bst1); remove(list1[n1/2], bst1); // removes list1[n1/2] from corresponding tree (bst1)

cout << "In-order traversal of bst1 after deleting " <

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

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions