We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf3c7c5 commit 93b1ee2Copy full SHA for 93b1ee2
Sorting/ShellSort/java/ShellSort.java
@@ -3,9 +3,11 @@ public class ShellSort{
3
public static int[] shellSort(int arr[]){
4
int temp;
5
int n = arr.length;
6
+ // Gap of size n/2 initially
7
for(int i = n/2; i>0; i=i/2){
8
for(int j = i; j<n; j++){
9
for(int k=j-i;k>=0;k=k-i){
10
+ // break loop if is higher, if not switch
11
if(arr[k+i]>=arr[k]){
12
break;
13
}else{
@@ -30,14 +32,13 @@ public static void main(String[] args) {
30
32
}
31
33
System.out.println();
34
- sortedArray = shellSort(array);
-
35
+ // shell sort
36
+ sortedArray = shellSort(array);
37
System.out.println("After: ");
38
n = sortedArray.length;
39
for (int i = 0; i < n; ++i) {
40
System.out.print(sortedArray[i] + " ");
41
42
43
-}
44
+}
0 commit comments