Question: Please explain with a pseudo code and show the time complexity calculation. Thank you. 1. If we have an algorithm that finds the kth-smallest element
Please explain with a pseudo code and show the time complexity calculation. Thank you.
1. If we have an algorithm that finds the kth-smallest element of an n element set, we can obtain an algorithm for finding the median element simply by calling the kth-smallest algorithm with k = ceiling((n+1)/2). This question asks you to do the converse. Given an algorithm that finds the median element of an n element set in Theta(n) time, design an algorithm that finds the kth-smallest element for arbitrary k in Theta(n) time using the median-finding algorithm. Be sure to analyze the running time of your algorithm.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
