Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 6, 9, 3, 7, 1 and 8 into it in that order), then searches for values 7 (which is in the tree) and 4 (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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

=+2 Why are international employment standards important to IHRM?

Answered: 1 week ago