Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
0 of .
Results for:
P. 1

Ratings: (0)|Views: 140|Likes:

### Availability:

See more
See less

01/12/2013

pdf

text

original

Name: Tanmay BaidRollNumber: 0829cs071112
Bubble Sort
# include<stdio.h># include<conio.h>void main(){int a[5], i, j, temp;clrscr();printf("Enter 5 elements of array: ");for(i=0;i<5;i++){scanf("%d",&a[i]);}for(i=0;i<5;i++){for(j=0;j<4;j++){if(a[j]>a[j+1]){temp=a[j];a[j]=a[j+1];a[j+1]=temp;}}}printf("Sorted array: ");for(i=0;i<5;i++){printf("\n%d",a[i]);}getch();}
1

Name: Tanmay BaidRollNumber: 0829cs071112Output
Enter 5 elements of array: 1 8 5 2 7Sorted array:12578
2

Name: Tanmay BaidRollNumber: 0829cs071112
Merge Sort
#include<stdio.h>#include<conio.h>void mergesort(int x[],int n){int aux[10],i,j,k,l1,u1,l2,u2,size;size=1;while(size<n){l1=0;k=0;while(l1+size<n){l2=l1+size;u1=l2-1;if(l2+size-1<n)u2=l2+size-1;elseu2=n-1;for(i=l1,j=l2;i<=u1 && j<=u2;k++){if(x[i]<x[j])aux[k]=x[i++];elseaux[k]=x[j++];}for(;i<=u1;k++)aux[k]=x[i++];for(;j<=u2;k++)aux[k]=x[j++];l1=u2+1;}
3