Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit 16f2fc1

Browse files
Update BubbleSort.java
adding comments on the method.
1 parent 356dfb1 commit 16f2fc1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎src/com/jwetherell/algorithms/sorts/BubbleSort.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
public class BubbleSort<T extends Comparable<T>> {
2222

2323
private BubbleSort() { }
24-
24+
//@param unsorted array
25+
//@return sorted array
2526
public static <T extends Comparable<T>> T[] sort(T[] unsorted) {
2627
boolean swapped = true;
2728
int length = unsorted.length;
@@ -37,7 +38,7 @@ public static <T extends Comparable<T>> T[] sort(T[] unsorted) {
3738
}
3839
return unsorted;
3940
}
40-
41+
//swapping the value
4142
private static <T extends Comparable<T>> void swap(int index1, int index2, T[] unsorted) {
4243
T value = unsorted[index1];
4344
unsorted[index1] = unsorted[index2];

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /