Question: (5) Design an algorithm that takes as input an n-element heap H and a key k and returns all the entries in H having a


(5) Design an algorithm that takes as input an n-element heap H and a key k and returns all the entries in H having a key greater than or equal to k. For example, given the heap below and query k = 8, the algorithm should report the entries with keys 16, 14, 10, 8, and 9 (but not necessarily in this order). Your algorithm should run in time proportional to the number r of entries returned, and should not modify the heap. You may assume that at least one entry will be returned. Note that r can be much smaller than n. 16 14 10 10 describe your algorithm using pseudocode, argue the correctness of your algorithm, and analyze the running time of your algorithm (that is, explain why it runs in (r) time)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
