Skip to content

Commit 7bd6082

Browse files
committed
fix bubble sort
1 parent c26630f commit 7bd6082

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎algorithms/src/main/java/com/baeldung/algorithms/bubblesort/BubbleSort.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class BubbleSort {
77
void bubbleSort(Integer[] arr) {
88
int n = arr.length;
99
IntStream.range(0, n - 1)
10-
.flatMap(i -> IntStream.range(i + 1, n - i))
10+
.flatMap(i -> IntStream.range(1, n - i))
1111
.forEach(j -> {
1212
if (arr[j - 1] > arr[j]) {
1313
int temp = arr[j];

‎algorithms/src/test/java/com/baeldung/algorithms/bubblesort/BubbleSortUnitTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.baeldung.algorithms.bubblesort;
22

3-
import static org.junit.Assert.*;
3+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
44

5-
import org.junit.Test;
5+
import org.junit.jupiter.api.Test;
66

77
public class BubbleSortUnitTest {
88

0 commit comments

Comments
 (0)