Question
This is a c++ program. Create a heap(max or min, choose one) class containing the standard functionality of insertion and removal. Use a dynamically-allocated array
This is a c++ program. Create a heap(max or min, choose one) 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 recursion of size is required.)
In addition, this heap allows the user to reset the priority of a given value on the heap so it moves to the top of the heap and is the next item removed. Testing this will require storing both the original priority and the charged priority, so plan your nodes appropriately. A priority can be a simple integer. Because this is a structure with dynamica memory in c++, you must include(and test) the memory m anagement methids.
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 both the origianl priority and updated priority(which are likely the same at this stage) to the screen(to test remove).
3) Changing the priority of a given node, and reorganizing the heap as needed. Then removing the next value from the heap and print both the original priority and update priority(which should now be different) to the screen( to test "resetting the priority".)
4) Be sure the user interface explains all tests and expected results.
Name the file heap.h, heap.cpp and p3.cpp.
NOTE: DO NOT USE THE WORD "BREAK" AND DONT USE CASE NUMBERS FOR THIS QUESTION.
DO NOT COPY AND PASTE FROM OTHER ANSWERS SIMILAR TO THIS QUESTIONS.
BE SURE TO INCLUDE A SCREENSHOOT OF YOUR TESTED PROGRAMMING ANSWER.
IT SHOULD BE C++
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