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

Example16Heap and provide functions in class Heap to implement basic heap operations,
including
Read non-negative integers from the user and use them to build a heap
Display the heap using the breadth-first 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 5 project.
Select from:
1. Read items and build heap
2. Display heap
3. Insert a node
4. Remove the largest node
5. Search for a key
0. Exit
1
Enter integers(negative to stop): 7223715395813934638-1
Select from:
1. Read items and build heap
2. Display heap
3. Insert a node
4. Remove the largest node
5. Search for a key
0. Exit
2
Heap:
95
7281
53387139
34623
Select from:
1. Read items and build heap
2. Display heap
3. Insert a node
4. Remove the largest node
5. Search for a key
0. Exit
3
Enter a non-negative integer to be inserted: 85
Select from:
1. Read items and build heap
2. Display heap
3. Insert a node
4. Remove the largest node
5. Search for a key
0. Exit
2
Heap:
95
8581
53727139
3462338
Select from:
1. Read items and build heap
2. Display heap
3. Insert a node
4. Remove the largest node
5. Search for a key
0. Exit
4
Select from:
1. Read items and build heap
2. Display heap
3. Insert a node
4. Remove the largest node
5. Search for a key
0. Exit
2
Heap:
85
7281
53387139
34623
Select from:
1. Read items and build heap
2. Display heap
3. Insert a node
4. Remove the largest node
5. Search for a key
0. Exit
5
Enter the key to be searched for: 71
71 found at index 5
Select from:
1. Read items and build heap
2. Display heap
3. Insert a node
4. Remove the largest node
5. Search for a key
0. Exit
5
Enter the key to be searched for: 25
25 NOT found
Select from:
1. Read items and build heap
2. Display heap
3. Insert a node
4. Remove the largest node
5. Search for a key
0. Exit
0
Thanks for using my program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!