Skip to content

Update shell sort documentation #2033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Sorts/ShellSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
public class ShellSort implements SortAlgorithm {

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

ShellSort sort = new ShellSort();
print(sort.sort(toSort));
sort.sort(toSort);
for (int i = 0; i < toSort.length - 1; ++i) {
assert toSort[i] <= toSort[i + 1];
}
print(toSort);
}
}