Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to find the kth smallest element in the given list of
array elemnts.

Answer Posted / khaja moulali shiak

int kmin(int a[],int n,int k)
{
int i;
int j;
int l;
int u;
int x;
int t;
l=1;
u=n;
while(l<u)
{
i=l;
j=u;
x=a[k];
while((i<=k)&&(j>=k))
{
while(a[i]<x) i++;
while(a[j]>x) j--;
swap(a[i],a[j]);
i++;
j--;
}
if(j<k) l=i;
if(i>k) u=j;
}
return(a[k]);
}

Is This Answer Correct ?    10 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you restore a redirected standard stream?

1134


What is property type c?

1099


What is New modifiers?

1141


Explain how can I manipulate strings of multibyte characters?

1217


What are the modifiers available in c programming language?

1241


What is the use of a static variable in c?

1071


How can I insert or delete a line (or record) in the middle of a file?

1028


What is function definition in c?

1089


How can I pad a string to a known length?

1048


When should a type cast be used?

1029


What is the 'named constructor idiom'?

1113


Can you pass an entire structure to functions?

1140


How can I convert a number to a string?

1214


Explain the red-black trees?

1143


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

1168