Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started