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 purpose of the preprocessor directive error?
What are identifiers in c?
List some applications of c programming language?
What are header files in c?
Explain what are the __date__ and __time__ preprocessor commands?
What are the uses of a pointer?
Tell me when is a void pointer used?
What are the different categories of functions in c?
What does int main () mean?
Why should I use standard library functions instead of writing my own?
In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
What are header files and explain what are its uses in c programming?
write a c program in such a way that if we enter the today date the output should be next day's date.
Why does this code crash?