Ask Question

Give an efficient algorithm to find all keys in a min heap that are smaller than a provided valueX. The provided valuedoes nothave to be a key in the min heap. Evaluate the time complexityof your algorithm.

+3
Answers (1)
  1. 15 April, 18:33
    0
    Starting from root, recursively traverse the min-heap. Once we find a key with value less than our X, we know that every key in subtree of that key will be also smaller than our X. Otherwise, we should keep traversing.

    Explanation:

    The complexity of this algorithm will be O (N) where N is the number of keys in our min-heap.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Give an efficient algorithm to find all keys in a min heap that are smaller than a provided valueX. The provided valuedoes nothave to be a ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers