From 7bd608207c8482d2511d8c0814e42e31feffe3cc Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 24 Oct 2018 22:29:28 +0300 Subject: [PATCH] fix bubble sort --- .../java/com/baeldung/algorithms/bubblesort/BubbleSort.java | 2 +- .../baeldung/algorithms/bubblesort/BubbleSortUnitTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/algorithms/src/main/java/com/baeldung/algorithms/bubblesort/BubbleSort.java b/algorithms/src/main/java/com/baeldung/algorithms/bubblesort/BubbleSort.java index a561072b2e..275cb7f3a2 100644 --- a/algorithms/src/main/java/com/baeldung/algorithms/bubblesort/BubbleSort.java +++ b/algorithms/src/main/java/com/baeldung/algorithms/bubblesort/BubbleSort.java @@ -7,7 +7,7 @@ public class BubbleSort { void bubbleSort(Integer[] arr) { int n = arr.length; IntStream.range(0, n - 1) - .flatMap(i -> IntStream.range(i + 1, n - i)) + .flatMap(i -> IntStream.range(1, n - i)) .forEach(j -> { if (arr[j - 1] > arr[j]) { int temp = arr[j]; diff --git a/algorithms/src/test/java/com/baeldung/algorithms/bubblesort/BubbleSortUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/bubblesort/BubbleSortUnitTest.java index c7f3f7dc38..c3260a18dd 100644 --- a/algorithms/src/test/java/com/baeldung/algorithms/bubblesort/BubbleSortUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/bubblesort/BubbleSortUnitTest.java @@ -1,8 +1,8 @@ package com.baeldung.algorithms.bubblesort; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class BubbleSortUnitTest {