QUICK SORT TYPE PROBLEMS
K’th Smallest/Largest Element in Unsorted Array | Set 2 (Expected Linear Time)
We recommend to read following post as a prerequisite of this post.
Given an array and a number k where k is smaller than size of array, we need to find the k’th smallest element in the given array. It is given that ll array elements are distinct.
Examples:
Input: arr[] = {7, 10, 4, 3, 20, 15} k = 3 Output: 7 Input: arr[] = {7, 10, 4, 3, 20, 15} k = 4 Output: 10
We have discussed three different solutions here.
-
No comments:
Post a Comment