Question: in c++ code only based on the following definition to implement a MAX-HEAP that will enable adoption of the oldest pet (by age) in our


based on the following definition to implement a MAX-HEAP that will enable adoption of the oldest pet (by age) in our Animal Shelter. We will use the STL vector class to store the MAX-HEAP. Note: You can define a swap function if you think it facilitates your implementation. fou should also have a runTests() function that: 1. inserts 10 pets of various ages, 2. displays the heap, 3. adopts a few pets, 4. displays number of pets left, 5. adopts all remaining pets, 6. attempts an adoption when no pets are available. Your lab should also have a user interface to help test each function above individually and quit the program. For example: Welcome on Basic Heap operations. What would you like to test? 1. Insert Pet 2. Adopt Pet 3. Number of Pets 4. Display Pets 5. Run Tests 6. Exit After inserting pets with ages 4,8,1,7,3, a call to Display Pets might look like: The pets in the heap in level order are: Pusheen 8, Garfield 7, Simba 1, Tigger 4, Felix 3, And after a call to Adopt Pet, the output might look like: Congratulations, you have adopted Pusheen, age 8. Similarly for Number of Pets: The shelter heap has 4 pets. Finally, make sure to free any dynamically allocated memory before quitting your program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
