Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started