Write a C program to find the n th largest or smallest number in a array without sorting.

It is very easy to find the largest number in the already sorted numbers. If the number is unsorted then we need to sort the array. After that we can easily find the n th largest number.

If we want to find the second largest number then we can get it by arr with n-1 th index. But here we have one twist.

We need to write the program to find the nth largest number without sorting the given array.

We strongly recommend you to try by yourself before scrolling down.

 

Compile: gcc filename.c [or] g++ filename.cpp

Output:

 

Now try to write a program to find the Nth smallest number.

Also if you find any error or alternate simple method let us know in the comments.