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 0183240 commit 37d4ce9Copy full SHA for 37d4ce9
algorithms/sorting/bubble-sort/bubble-sort-2.js
@@ -47,7 +47,7 @@ function bubbleSort(items){
47
i, j;
48
49
for (i=len-1; i >= 0; i--){
50
- for (j=len-i; j >= 0; j--){
+ for (j=len-i-1; j >= 0; j--){
51
if (items[j] < items[j-1]){
52
swap(items, j, j-1);
53
}
algorithms/sorting/bubble-sort/bubble-sort.js
i, j, stop;
for (i=0; i < len; i++){
- for (j=0, stop=len-i; j < stop; j++){
+ for (j=0, stop=len-i-1; j < stop; j++){
if (items[j] > items[j+1]){
swap(items, j, j+1);
0 commit comments