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.

Answers were Sorted based on User's Feedback



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

Answer / jyothi

first the given list must be sorted using any of the
sorting tecniques and then taking the kth element in that
resultent array will give the answer
or
another tecnique is using quick sort it will be easier
and time complexity is also very less.sorry i dont have
enough time to write the program here dontmind

Is This Answer Correct ?    25 Yes 13 No

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

Answer / 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

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

Answer / siva

This is a problem of Kth smallest element of QUICK SORT technique

Is This Answer Correct ?    6 Yes 2 No

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

Answer / newclient

sorting is not required in this case.u can still use same
technique(not exactly) as mentioned in Cormen.an algorithm
named "QuickSelect" which has an average complexity of
O(nlong(n)).
Anyways to reduce the number of comparisions one can use
tournament algorithm and for kth element we have to
recursively go through the loosers list.

Is This Answer Correct ?    9 Yes 6 No

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

Answer / sunil

This is a problem of "Order statistics". A good link describing all possible solutions along with code and output is at below link.

http://www.rawkam.com/?p=870

Is This Answer Correct ?    1 Yes 4 No

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

Answer / sumesh

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,s,c=0; clrscr();
printf("enter the elements in the list :\n");
for(i=0;i<=9;i++)
{
scanf("%d",&a[i]);
}
s=a[0];
for(i=1;i<=9;i++)
{
if(s>a[i])
{
s=a[i];
c++;
break;
}
}
printf("small is\t %d\nfound on\t %d\n",s,c+1);
getch();
}

Is This Answer Correct ?    0 Yes 3 No

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

Answer / ruchi

#include<stdio.h>
#include<conio.h>
int main()
{
int a[10],i,j,n,temp;
printf("\nEnter the number of elements int he array ");
scanf("%d",&n);
printf("\nEnter the elements ");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("\nThe smallest element is ");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
break;
}
getch();
}

Is This Answer Correct ?    12 Yes 28 No

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

Answer / shil

#include <stdio.h>
#include<conio.h>
main()
{
int a[20], i,n;
printf("ent how many elements u want to enter");
scanf("%d",&n);
printf("enter the elements");
for(i=1;i<=n;i++)
scanf("%d",&a[i]));
s=a[1];
for(i=2;i<=n;i++)
{
if
{
s>a[i]
s=a[i]
}
}
printf("the smallest element is %d",s);
}

hope this correct if it is wrong plz let me know

Is This Answer Correct ?    19 Yes 60 No

Post New Answer

More C Interview Questions

what would be the output of the following program? main() { int k = 123; char *ptr; ptr = &k; printf("%d",*ptr); }

4 Answers  


f(*p) { p=(char *)malloc(6); p="hello"; return; } main() { char *p="bye"; f(p); printf("%s",p); } what is the o/p?

7 Answers   Hughes,


Can the curly brackets { } be used to enclose a single line of code?

0 Answers  


What is floating point exception error? And what are different types of errors occur during compile time and run time? why they occur?

1 Answers  


? ???Mirror Mirror on the wall????????

1 Answers   channel V, DPI,


Difference between macros and inline functions? Can a function be forced as inline?

0 Answers   HAL, Honeywell, Zomato,


Can we write a program without main() function?

9 Answers  


Why is c fast?

0 Answers  


What is the purpose of Scanf Print, getchar, putchar, function?

3 Answers  


What will the code below print when it is executed?   int x = 3, y = 4;         if (x = 4)                 y = 5;         else                 y = 2;         printf ("x=%d, y=%d ",x,y);

0 Answers  


What is the modulus operator?

0 Answers  


to get a line of text and count the number of vowels in it

3 Answers   Satyam,


Categories