Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is the quastion,, i dont have ant output for it. if cant then pls refund the question back Question 5: This exercise aims at

image text in transcribed

this is the quastion,, i dont have ant output for it. if cant then pls refund the question back

Question 5: This exercise aims at making you appreciate features that we often take for granted in a modern programming language, but did not exist before. Since it is not quite reasonable to learn, say, old Fortran just for one assignment, you will code the following in C++, while pretending it is limited like Fortran was. Specifically, your program should only use static variables and arrays to store data. In other words, you must assume all memory is allocated at compile-time; that means no pointers, no dynamic memory, no records or classes, etc. (If in doubt, please ask.) Your task is to implement a Binary Search Tree (BST) of integers and its init(), insert(), and find() functions and only those. The idea is to use a number of static arrays to store the same data that BST nodes normally contain, and implement the three BST functions accordingly. (Note that you cannot use the single array method discussed in CMP 305, which is very inefficient memory wise.) Make sure your code is well readable (use good variable names, add comments as needed...) To validate your implementation, write a test program that creates a new BST, inserts integers 4, 9, 1, 8, 2 and 7 into it (in that order), then searches for values 7 (which is in the tree) and 0 (which is not). Make sure to print the BST data (i.e., the content of your arrays) after each insertion. Likewise, add print statements as necessary to trace the retrieval process (find). Hand in your source code, comments, and full trace as indicated above. (7 marks) Question 5: This exercise aims at making you appreciate features that we often take for granted in a modern programming language, but did not exist before. Since it is not quite reasonable to learn, say, old Fortran just for one assignment, you will code the following in C++, while pretending it is limited like Fortran was. Specifically, your program should only use static variables and arrays to store data. In other words, you must assume all memory is allocated at compile-time; that means no pointers, no dynamic memory, no records or classes, etc. (If in doubt, please ask.) Your task is to implement a Binary Search Tree (BST) of integers and its init(), insert(), and find() functions and only those. The idea is to use a number of static arrays to store the same data that BST nodes normally contain, and implement the three BST functions accordingly. (Note that you cannot use the single array method discussed in CMP 305, which is very inefficient memory wise.) Make sure your code is well readable (use good variable names, add comments as needed...) To validate your implementation, write a test program that creates a new BST, inserts integers 4, 9, 1, 8, 2 and 7 into it (in that order), then searches for values 7 (which is in the tree) and 0 (which is not). Make sure to print the BST data (i.e., the content of your arrays) after each insertion. Likewise, add print statements as necessary to trace the retrieval process (find). Hand in your source code, comments, and full trace as indicated above. (7 marks)

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

2. Why have many large organizations used assessment centers?

Answered: 1 week ago