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
What is the benefit of using const for declaring constants?
Is javascript written in c?
What is a method in c?
What is the difference between text files and binary files?
What is #include stdio h?
What is preprocessor with example?
What are enumerated types?
What is structure padding in c?
Are the variables argc and argv are local to main?
Is calloc better than malloc?
Hai what is the different types of versions and their differences
What is static identifier?
Why is python slower than c?
What does c mean in basketball?
What is the c value paradox and how is it explained?