← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Design and implement a Min Heap data structure that supports the following operations efficiently:
insert(value): Insert a new integer into the heap.extract_min(): Remove and return the smallest element in the heap. If the heap is empty, return None.peek_min(): Return the smallest element without removing it. If the heap is empty, return None.Internally represent the heap as a dynamic array (Python list). Maintain the min-heap property: for every node i other than the root, the value of i is greater than or equal to the value of its parent. You must implement the helper “bubble-up” routine used after insertion and the “bubble-down” (heapify-down) routine used after extraction. Do not use any built-in heap libraries.