Question: Create a MinHeap class with the appropriate insert and delete method. The constructor will receive a capacity parameter to determine the capacity of the heap

Create a MinHeap class with the appropriate insert and delete method. The constructor will receive a capacity parameter to determine the capacity of the heap array. In addition, create a sort method inside the MinHeap class to sort the array (representing heap) using heapsort.
Note:
The MinHeap Class will have two instance variables; An Array & the size of the heap. Moreover, itll have 4 functions/methods; insert(), swim(), extractMin(), sink(), sort().
The instance variables must be Private.
Hint: Use a size variable inside the heap class to maintain the size of the heap. Note that the length of the array and the size of the heap are not the same!

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!