SHELL - { int n,i,arr[50]; clrscr(); printf("Enter the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<conio.h> /* RISHI AGARWAL SHELL SORT ROLL NO 02 SE CMPN A */ * void display(int a[],int n) { int i; printf("\nLIST\n"); for(i=0;i<n;i++) printf("%d ",a[i]); } void shellsort(int a[],int n) { int span,i,j,x; span=n/2; while(span>=1) { for(i=span;i<n;i++) { x=a[i]; j=i; { printf("\nComparing %d %d",a[j-span],x); a[j]=a[j-span]; j=j-span; } a[j]=x; } printf("\nList:"); for(i=0;i<n;i++) printf("%d ",a[i]); span=span/2; } } void main()
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { int n,i,arr[50]; clrscr(); printf("Enter the no of data:"); scanf("%d",&n); printf("Enter the nos"); for(i=0;i<n;i++) scanf("%d",&arr[i]); //Displaying List display(arr,n); // Shell Sort shellsort(arr,n); //Displaying Sorted List display(arr,n); getch(); } /* OUTPUT: Enter the no of data:10 Enter the nos100 80 90 70 50 60 10 40 30 20 LIST 100 80 90 70 50 60 10 40 30 20 LIST 10 20 30 40 50 60 70 80 90 100 */...
View Full Document

This note was uploaded on 10/25/2010 for the course CMPN SEM4 taught by Professor Thakur during the Spring '07 term at University of Mumbai.

Page1 / 2

SHELL - { int n,i,arr[50]; clrscr(); printf("Enter the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online