fix bubble sort

This commit is contained in:
Loredana Crusoveanu 2018-10-24 22:29:28 +03:00
parent c26630f046
commit 7bd608207c
2 changed files with 3 additions and 3 deletions

View File

@ -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];

View File

@ -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 {