Program to find Kth smallest element in an unsorted array

Program to find Kth smallest element in an unsorted array

The program to find the Kth smallest element in an unsorted array is discussed here.

Program to find Kth smallest element in an unsorted array


Write a program to print the kth smallest number from the array:

For example:

Sample Input:

10 (Number of elements of the array)

5 (Kth smallest element to be found)

1 2 7 8 9 3 4 5 6 0 (Array elements)

Sample Output:

4


face prep pro ad bannerClick here to learn more about FACE Prep PRO


Algorithm to find the Kth smallest element in an unsorted array

  • Input the number of elements of the array.
  • Input the Kth element to be found.
  • Input the elements of the array.
  • Sort the array.
  • Return the arr[k-1].

Program to find the Kth smallest element in an unsorted array

@@coding::1@@


face prep pro ad banner


Recommended Programs


Program to find Kth smallest element in an unsorted array

c