Can both insert and findMin be implemented in constant time?
Read moreTextbook Solutions for Data Structures and Algorithm Analysis in Java
Question
3 Show the result of performing three deleteMin operations in the heap of theprevious exercise.
Solution
Step 1 of 2
Consider that the below heap to apply the deleteMin operation:
The deleteMin operation deletes the minimum value from the heap, which is the root. In a heap above, when 1 is deleted, the root candidates will be 3 and 2. To satisfy the heap order, choose the minimum value that is 2. This follows down the length of the heap in a similar fashion. The heap after the first deletion is given below:
The second deleteMin operation will delete the next minimum value from the heap, which is the root again. In the heap above, when 2 will be deleted, the candidates for the root will be 3 and 4. To satisfy the heap order, choose the minimum value that is 3. This follows down the length of the heap in a similar fashion. The heap after the second deletion is given below:
full solution