Exercise: Heaps
Implement the remove(i) method in the binary heap.
We'll cover the following
Task
Implement the remove(i)
method, that removes the value stored in a[i]
in a BinaryHeap
. This method should run in time.
Sample input
The sample input will be as follows:
[0, 1, 2, 3, 4, 5, 6]
Expected output
The expected output will be as follows:
Original Heap:
[0, 1, 2, 3, 4, 5, 6]
Heap after removal from index 2:
[0, 1, 5, 3, 4, 6]
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy