Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this project, you will construct a BST with the keys that are in the given input file. The BST has the following properties: its

image text in transcribedimage text in transcribedimage text in transcribed

In this project, you will construct a BST with the keys that are in the given input file. The BST has the following properties: its nodes are distributed over 3Llogu n] depth levels; it provides the best possible total access time (as that asked in midterm exam) You will develop an algorithm that reads the keys from input.txt file and inserts the keys to the BST with the properties as defined above. After constructing the BST, your program will print the depth level of the BST, and the number of nodes in each depth level. Next any key may be searched for in the BST. If the key is in the BST, the program's output will be the depth level and the distance to the leftmost node, otherwise the output will be the following message: "The key is not in the tree." The BST should have at least 16 nonnegative and non-replicated keys, you have to control the input file, if input file contains less and/or negative keys then the program produces an error message. The name of the input file must be "input.txt" and it should be at the same directory with your source code. (I won't check the path and the name of your input file. When I run your program if the path or source file is not found, I will not evaluate your code.) The input file contains strictly positive (i.e., excluding 0) integers separated with space in a line. An example follows: 0 10 5 3 25 70 97 115 2 65 69 32 152 1 21 49 8 12 78 Example Run: 12 78 25 115 21 65 97 152 Output: Depth level of BST is 6 Depth level 01 Depth level 1+2 Depth level 274 Depth level 3 8 Depth level 4+2 Depth level 571 Key value to be searched (Enter 0 to exit) : 32 At Depth level 3, 4th element Key value to be searched (Enter 0 to exit) : 152 At Depth level 3, 8th element Depth level 24 Depth level 378 Depth level 42 Depth level 5 +1 Key value to be searched (Enter 0 to exit) : 32 At Depth level 3, 4th element Key value to be searched (Enter 0 to exit) : 152 At Depth level 3, 8th element Key value to be searched (Enter 0 to exit) : 78 At Depth level 1, 2nd element Key value to be searched (Enter 0 to exit) : 4 4 is not found in BST Key value to be searched (Enter 0 to exit) : 0 Exit

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

Explain the forces that influence how people handle conflict

Answered: 1 week ago