Question: Problem 6 ( Heap - find operation ) Let H be a heap storing n elements. We want to find the set of all elements
Problem Heapfind operation
Let H be a heap storing n elements. We want to find the set of all elements in H whose keys are
less than or equal to the given key k
Example: given the heap on p and we would return the four elements with keys
in some order.
a Find an time algorithm for this ind operation, where is the number of elements
returned. Give an English description as well as detailed pseudocode.
Hint: you can use stacks or queues to help you, as we did for BreadthFirstSearch.
b Prove that your algorithm is correct. Meaning, that it returns all the desired elements, and only
the desired elements.
Problem Heapfind operation
Let H be a heap storing n elements. We want to find the set of all elements in H whose keys are
less than or equal to the given key
Example: given the heap on p and we would return the four elements with keys
in some order.
a Find an time algorithm for this find operation, where m is the number of elements
returned. Give an English description as well as detailed pseudocode.
Hint: you can use stacks or queues to help you, as we did for BreadthFirstSearch.
b Prove that your algorithm is correct. Meaning, that it returns all the desired elements, and only
the desired elements.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
