Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

in c++ code only
image text in transcribed
image text in transcribed
image text in transcribed
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

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

Why are so many people afraid of communication?

Answered: 1 week ago