Question: Example 1 6 Heap and provide functions in class Heap to implement basic heap operations, including Read non - negative integers from the user and
ExampleHeap and provide functions in class Heap to implement basic heap operations,
including
Read nonnegative integers from the user and use them to build a heap
Display the heap using the breadthfirst traversal so that nodes in different levels
will be printed in different lines
Insert a new node into the heap
Remove the largest node from the heap
Search the heap for a specified key and print the index of the key in the array
For this project, lets assume keys in the heap are distinct.
In addition, you will also write necessary statements in main function to allow users to
choose from a menu of options and manipulate the heap. Here are some examples when
running the Homework project.
Select from:
Read items and build heap
Display heap
Insert a node
Remove the largest node
Search for a key
Exit
Enter integersnegative to stop:
Select from:
Read items and build heap
Display heap
Insert a node
Remove the largest node
Search for a key
Exit
Heap:
Select from:
Read items and build heap
Display heap
Insert a node
Remove the largest node
Search for a key
Exit
Enter a nonnegative integer to be inserted:
Select from:
Read items and build heap
Display heap
Insert a node
Remove the largest node
Search for a key
Exit
Heap:
Select from:
Read items and build heap
Display heap
Insert a node
Remove the largest node
Search for a key
Exit
Select from:
Read items and build heap
Display heap
Insert a node
Remove the largest node
Search for a key
Exit
Heap:
Select from:
Read items and build heap
Display heap
Insert a node
Remove the largest node
Search for a key
Exit
Enter the key to be searched for:
found at index
Select from:
Read items and build heap
Display heap
Insert a node
Remove the largest node
Search for a key
Exit
Enter the key to be searched for:
NOT found
Select from:
Read items and build heap
Display heap
Insert a node
Remove the largest node
Search for a key
Exit
Thanks for using my program.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
