Question
Heap using dynamically allocated array in C++ Create a Heap (min or max,, your choice) class containing the standard functionality of insertion and removal .
Heap using dynamically allocated array in C++
Create a Heap (min or max,, your choice) class containing the standard functionality of insertion and removal . Use a dynamically - allocated array for storage of your heap, allowing the heap to grow as needed (no reduction of size is required).
In addition, this heap allows the user to flush a value from the heap. In other words, the user supplies a value and the heap removes all instances of that value automatically.
Because this is a structure with dynamic memory in C++, you must include the memory management methods.
In your driver, test the heap by:
1) Inserting more than the default size number of values (to test insertion and resize)
2) Removing the next value and printing it to the screen (to test remove)
3)Flushing a given value from the hea, then removing and printing values until it is clear the flushed value has been removed (to test flush)
Note that you must know a value is on the heap to know if your flush method removed it. Consequently, you must either insert one (or more) known values on the heap, or track one (or more) of the random values.
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