Skip to content

Commit 486ebc2

Browse files
Update shell sort documentation (TheAlgorithms#2033)
1 parent b75bfe3 commit 486ebc2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Sorts/ShellSort.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
public class ShellSort implements SortAlgorithm {
66

77
/**
8-
* This method implements Generic Shell Sort.
8+
* Implements generic shell sort.
99
*
10-
* @param array the array to be sorted
10+
* @param array the array to be sorted.
11+
* @param <T> the type of elements in the array.
12+
* @return the sorted array.
1113
*/
1214
@Override
1315
public <T extends Comparable<T>> T[] sort(T[] array) {
@@ -37,6 +39,10 @@ public static void main(String[] args) {
3739
Integer[] toSort = {4, 23, 6, 78, 1, 54, 231, 9, 12};
3840

3941
ShellSort sort = new ShellSort();
40-
print(sort.sort(toSort));
42+
sort.sort(toSort);
43+
for (int i = 0; i < toSort.length - 1; ++i) {
44+
assert toSort[i] <= toSort[i + 1];
45+
}
46+
print(toSort);
4147
}
4248
}

0 commit comments

Comments
 (0)