Question: Let A be an array containing n integers. One could find the kth smallest integer in A by sorting A into increasing order using insertion
Let A be an array containing n integers. One could find the kth smallest integer in A by sorting A into increasing order using insertion sort, which requires O(n^2) time. The kth smallest element in A is then A[k]. There are faster sorting algorithms, which require O(nlgn) time. So one could find the kth smallest element in A in O(nlgn) time. Give an algorithm to find the kth smallest element that is more efficient when k< lgn. 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
