BAEL-3194: Radix Sort in Java (changed the method name to comply with site standards) (#7761)
This commit is contained in:
parent
fe94b62375
commit
dc1cd98cd0
|
@ -29,7 +29,7 @@ public class RadixSort {
|
||||||
frequency[digit]++;
|
frequency[digit]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < 10; i++) {
|
for (int i = 1; i < range; i++) {
|
||||||
frequency[i] += frequency[i - 1];
|
frequency[i] += frequency[i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.junit.Test;
|
||||||
public class RadixSortUnitTest {
|
public class RadixSortUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenUnsortedArrayWhenRadixSortThenArraySorted() {
|
public void givenUnsortedArray_whenRadixSort_thenArraySorted() {
|
||||||
int[] numbers = { 387, 468, 134, 123, 68, 221, 769, 37, 7 };
|
int[] numbers = { 387, 468, 134, 123, 68, 221, 769, 37, 7 };
|
||||||
RadixSort.sort(numbers);
|
RadixSort.sort(numbers);
|
||||||
int[] numbersSorted = { 7, 37, 68, 123, 134, 221, 387, 468, 769 };
|
int[] numbersSorted = { 7, 37, 68, 123, 134, 221, 387, 468, 769 };
|
||||||
|
|
Loading…
Reference in New Issue