Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 me, and False if it is less than .. (4 points) Write pseudocode for your algorithm (2 points) Prove that you algorithm is correct. (2 points) Analyze your algorithm's running time. Now give an algorithm to find the kth smallest element in an array-based min-heap on n elements in O(k log k) time. No credit will be given for O(k log n) solutions. (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 me, and False if it is less than .. (4 points) Write pseudocode for your algorithm (2 points) Prove that you algorithm is correct. (2 points) Analyze your algorithm's running time. Now give an algorithm to find the kth smallest element in an array-based min-heap on n elements in O(k log k) time. No credit will be given for O(k log n) solutions. (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
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