Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 1 Suppose that you have a black - box worst - case linear - time median subrou - tine, FindMedian. Give a simple, linear
Exercise Suppose that you have a blackbox worstcase lineartime median subrou tine, FindMedian. Give a simple, lineartime algorithm that find the kth order statistics for an array A of integers
Exercise Give an On algorithm that, given a array A of n distinct integers and a positive integer k n determines the k numbers in S that are closest to the median of A
Exercise Argue the correctness of BuildMaxHeap
BuildMaxHeapA n
: Aheapsize n
: forindowntodo : MaxHeapifyA i
by proving the following loop invariant: At the start of each iteration of the for loop of lines each node iin is the root of a maxheap
Exercise Give an On lg ktime algorithm to merge k sorted lists into one sorted list, where n is the total number of elements in all the input lists Hint: use a minheap for kway merging
Exercise Suppose in the algorithm SELECT median of medians the input elements are divided into groups of instead of to find the ith smallest element in a array A of size n Show that the worst case running time of this modified algorithm is defined by:
Tn Tn Tn n then use induction to show that Tn is On
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