For the following given data below draw the Max-Heap Data is: 15, 3, 6, 18, 5, 9, 11, 20, 17, 7, 2, 3, 14 | PU | Past Paper 2017

UNIVERSITY OF THE PUNJAB

Fourth Semester 2017

Examination: B.S. 4 Years Programme 

Paper: Data Structure and Algorithm

Course Code: IT-207 / IT-22408

Short Questions

c) For the following given data below draw the Max-Heap

Data is:

15, 3, 6, 18, 5, 9, 11, 20, 17, 7, 2, 3, 14

Solution:
Insert(15);
Insert(3); 
Insert(6);
Insert(18);
heapify Up();
Insert(5);

Insert(9);
heapify Up();
Insert(11);
heapify Up();
Insert(20);
heapify Up();
Insert(17);
heapify Up();
Insert(7);
heapify Up();
Insert(2);
Insert(3);
Insert(14);
heapify Up();
Ans:
     
Let me know in the comment section if you have any question.

Previous Post:
What is the output of the following code | PU | Past Paper 2017


Comments