8000 Update shell sort documentation · JavaInCloud/Java@39fb013 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 39fb013

Browse files
Update shell sort documentation
1 parent b75bfe3 commit 39fb013

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Sorts/ShellSort.java

Lines changed: 9 additions & 3 deletions
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)
0