0 votes 0 votes You are given a heap containing N elements. Write a procedure which takes as input a parameter k, and outputs the k'th smallest number in the heap. The running time of the procedure must depend on k alone. DS data-structures binary-heap time-complexity descriptive iitd-phd + – Aboveallplayer asked Dec 1, 2016 • recategorized Jul 7, 2022 by Lakshman Bhaiya Aboveallplayer 682 views answer comment Share Follow See 1 comment See all 1 1 comment reply mcjoshi commented Dec 1, 2016 reply Follow Share I assume you mean min-heap. kth smallest element will surely be present in first k levels. In worst case it can be at $k^{th}$ level. So, search all elements till that level. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes I'd advice u to meet thelink given below. It'll for sure answer your question. The explanation is indeed very good. Consider visiting once. Hope it helps u. :) http://algorithms.tutorialhorizon.com/binary-min-max-heap/ Devshree Dubey answered Dec 1, 2016 Devshree Dubey comment Share Follow See 1 comment See all 1 1 comment reply Aboveallplayer commented Dec 1, 2016 reply Follow Share Thanks a lot 0 votes 0 votes Please log in or register to add a comment.