Like us on Facebook and stand a chance to win pen drives!

Showing posts with label daa. Show all posts





Download


Download





#include<stdio.h>
int main()
{
  int array[11];
   int i;
    for(i=1;i<11;i++)
     {
        printf("Enter N0 :",i);
        scanf("%d", &array[i]);
     }
int n=11;
int j;
for (j=1;j<11;j++)
{
 int smallest= j;
 int i=0;
 for (i=j+1;i<11;i++)
 {
  if (array[i]<array[smallest])
  {
  smallest = i;
   int temp=array[j];
  array[j]=array[smallest];
         array[smallest]=temp;
  smallest=j;
  }
 }
}

  int m;
  for(m=1;m<11;m++)
   {
      printf("array[%d]=%d\n",m,array[m]);
}
}




#include<stdio.h>
int main()
{
  int array[10];
   int i;

    for(i=1;i<11;i++)
     {
        printf("Enter N0 :",i);
        scanf("%d", &array[i]);
     }
   int j,key,y;
   for(j=2;j<11;j++)
    {
       y=1;
        while(array[j]>array[y])
               y=y+1;
          key=array[j];
       int k;
       for(k=0;k<=(j-y-1);k++)
        {
            array[j-k]=array[j-k-1];
        }
   array[y]=key;
    }
  int m;
  for(m=1;m<11;m++)
   {
      printf("%d\n",array[m]);
   }
}



#include<stdio.h>
int partition(int a[],int b,int c);
void qsort(int a[],int p,int r);
int main()
{
  int a[6],i;
  for(i=0;i<6;i++)
  {
    printf("a[%d]element  :",i);
    scanf("%d",&a[i]);
  }
    qsort(a,0,5);
int l;
for(l=0;l<6;l++)
{
    printf("Elements a[%d]=%d\n",l,a[l]);
}  
return 0;
}
int partition(int a[],int b,int c)
{
   int x,i,j,temp1,temp2;
     x= a[c];
     i=b-1;
 for(j=b;j<5;j++)
 {
    if(a[j]<=x)
     {
         i=i+1;
         temp1=a[i];
         a[i]=a[j];
         a[j]=temp1;
      }
  }
    temp2=a[5];
    a[5]=a[i+1];
    a[i+1]=temp2;

 printf("Partition point is  %d\n",i+1);
 return(i+1);

}   
void qsort(int a[],int p,int r)
{
  int q;
   if(p>=r)
    {
       return;
    }
  else
    {
      q=partition(a,p,r);
      qsort(a,p,q-1);
      qsort(a,q+1,r);
    }
    }

Copyright © 2012 SLIIT Helper.