Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In class, we saw a deterministic O(n) time algorithm to compute the kth smallest element in an unsorted array S of n numbers. The main
In class, we saw a deterministic O(n) time algorithm to compute the kth smallest element in an unsorted array S of n numbers. The main idea to get the linear time algorithm was to find a good pivot element. This was done by partitioning the array S into n/5 sets of size 5. Then computing the median of each of these sets of size 5, resulting in a set of n/5 medians. The pivot element is the median of these n/5 medians and is computed recursively. What if we partition the array S into n/3 elements of size 3, instead. (a How many elements are guaranteed to be smaller than the pivot and how many are guaranteed to be larger than the pivot? Explain your reasoning (you do not need to give a formal proof). Give the recurrence for the new running time of the algorithm. Solve the recurrence using any method of your choice and state the running time of the algorithm in terms of n using Big-0h notation
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