In the BinaryHeap class, implement public int smallest(int k)
which returns the kth smallest element stored in this the BinaryHeap.
For example, if the heap contains the elements h=[4,10,20,12,12,30,24] then smallest(1)returns 4, smallest(2) returns 10, smallest(3)returns 12, as does smallest(4) and so on. You may assume that the input k is an integer between 1 and size().
The code in Java please.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here