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

What are the modifiers available in c programming language?

987


What is main () in c?

787


Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.

1849


For what purpose null pointer used?

811


Is main is a keyword in c?

850


What are different types of pointers?

781


Array is an lvalue or not?

859


What is calloc in c?

882


Do you know pointer in c?

809


Is c is a middle level language?

806


How are Structure passing and returning implemented by the complier?

924


When should a type cast not be used?

835


On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

917


What is extern keyword in c?

874


What are called c variables?

780