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 are the modifiers available in c programming language?
What is main () in c?
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.
For what purpose null pointer used?
Is main is a keyword in c?
What are different types of pointers?
Array is an lvalue or not?
What is calloc in c?
Do you know pointer in c?
Is c is a middle level language?
How are Structure passing and returning implemented by the complier?
When should a type cast not be used?
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
What is extern keyword in c?
What are called c variables?