SORTING USING SHELL SORT

630

 

SORTING USING SHELL SORT

BCA third semester

data structure

#include<stdio.h>
#include<conio.h>
int array[5];
void ShellSort(int *array, int n)
{
int i,j,iter, jter, increment, temp;
for(increment = n/2;increment > 0; increment /= 2)
{
for(i = increment; i<n; i++)
{
temp = array[i];
for(j = i; j >= increment ;j-=increment)
{
if(temp < array[j-increment])
{
array[j] = array[j-increment];
}
else
{
break;
}
}
array[j] = temp;
}
}
}

int main()
{
int n, iter;
printf(“Enter The Total Number Of Array Elements : “);
scanf(“%d”,&n);

for(iter = 0;iter < n;iter++)
{
printf(“Enter the Element : “);
scanf(“%d”,&array[iter]);
}
/* Calling this functions sorts the array */
ShellSort(array,n);
printf(“After Shell Sorting : \n”);
for(iter = 0;iter < n;iter++)
{
printf(“%d “,array[iter]);
}
printf(“\n”);
getch();
return 0;
}

OUTPUT
Enter The Total Number Of Array Elements : 5

Enter element : 40
Enter element : 10
Enter element : 30
Enter element : 60
Enter element : 20

After Shell Sorting :
10
20
30
40
60

 

 

if you need a Downloadable link once message us on-page you can get at a time.

m.me/bcanotesnepal

This post is posted for not further third-party purposes.

Copyright By:-  Bcanotesneapl

Not allowed to upload these notes to other sites.

Like our Facebook Page https://www.facebook.com/bcanotesnepal/

if you want to download this PDF comment on us we will provide you a downloadable link.

if you like please share this post with your friend who studies in BCA

if you have any query please comment below,

if you like our sites. you can visit again for the latest updates notes of different BCA subjects of Presentation and different topics with assignment questions and solutions.

Don’t forget to like our page and post also share with your friend and having your group.

if you have any questions you can drop or share them with me using the comment box I will try to answer your question.

Like our Facebook Page https://www.facebook.com/bcanotesnepal/

LEAVE A REPLY

Please enter your comment!
Please enter your name here