Question: 2 Q2: Binary heaps Given an min-heap H on n elements and a real number 1, give an algorithm to determine whether the kth smallest

 2 Q2: Binary heaps Given an min-heap H on n elements

2 Q2: Binary heaps Given an min-heap H on n elements and a real number 1, give an algorithm to determine whether the kth smallest element in H is greater than or equal to r. Your algorithm should run in O(k) time in the worst case, independent of the size of the heap. Note: You do not need to actually find the kth smallest element, you just need to return True if it is greater than or equal to x, and False if it is less than r. (4 points) Write pseudocode for your algorithm. (2 points) Prove that your algorithm is correct. (2 points) Analyze your algorithm's running time. 2 Q2: Binary heaps Given an min-heap H on n elements and a real number 1, give an algorithm to determine whether the kth smallest element in H is greater than or equal to r. Your algorithm should run in O(k) time in the worst case, independent of the size of the heap. Note: You do not need to actually find the kth smallest element, you just need to return True if it is greater than or equal to x, and False if it is less than r. (4 points) Write pseudocode for your algorithm. (2 points) Prove that your algorithm is correct. (2 points) Analyze your algorithm's running time

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!