Skip to content

Commit e334644

Browse files
Merge pull request #33 from Annex5061/main
hacktoberfest
2 parents 09a3d70 + f1a4381 commit e334644

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

shell.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package Sorting;
2+
3+
public class shell {
4+
5+
public static void main(String args[])
6+
{
7+
int[] a={9, 8, 3, 56, 5, 6, 4, 1};
8+
int length=a.length;
9+
10+
11+
int gap=length/2;
12+
// System.out.println(gap);
13+
while(gap>0)
14+
{
15+
for(int i=gap;i<length;i++)
16+
{
17+
int temp=a[i];
18+
// System.out.println((temp));
19+
20+
int j=i;
21+
// System.out.println((j));
22+
23+
while(j>=gap && a[j-gap]>temp)
24+
{
25+
// System.out.println(a[j]);
26+
a[j]=a[j-gap];
27+
// System.out.println(a[j]);
28+
j=j-gap;
29+
30+
a[j]=temp;
31+
// System.out.println(a[j]);
32+
33+
}
34+
35+
36+
}
37+
38+
gap=gap/2;
39+
40+
41+
}
42+
for(int i=0;i<length;i++)
43+
{
44+
System.out.println(a[i]);
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)