Exp 6
Exp 6
NO: 6:
Heap Implementation
AIM:
ALGORITHM:
1. Call the buildMaxHeap() function on the list. Also referred to as heapify(), this
OUTPUT :
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 1
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 2
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 3
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap41
5.Exit
Enter your choice: 1
Enter the element to be inserted: 4
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 5
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 9
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap: Heap --> 1 2 3 4 5 9
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 1
Enter the element to be inserted: 7
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap: Heap --> 1 2 3 4 5 9 7
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 2
Element Deleted
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 4
Displaying elements of Hwap: Heap --> 2 4 3 7 5 9
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice: 3
Minimum Element: Minimum Element: 2
-------------------------
Operations on Heap
-------------------------
1.Insert Element
2.Delete Minimum Element
3.Extract Minimum Element
4.Print Heap
5.Exit
Enter your choice:
RESULT:
Thus the C++ program to Heap tree was written, executed and verified successfully .