Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/sorts/CycleSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public <T extends Comparable<T>> T[] sort(T[] arr) {
int count = 0;

// Traverse array and put the elements on their respective right places
for (int i = 0; i < n - 2; i++) {
for (int i = 0; i < n - 1; i++) {

// Initialize item as the starting point
T item = arr[i];
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/sorts/SortUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static <T extends Comparable<T>> boolean less(T v, T w) {
* @param right is a right flip border of the array
*/
static <T extends Comparable<T>> void flip(T[] array, int left, int right) {
while (left <= right) {
while (left < right) {
swap(array, left++, right--);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/dataStructures/StackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void testPeekWithElements() {
myStack.push(30);
myStack.push(40);

Assertions.assertEquals(40, myStack.peek());
Assertions.assertEquals(40, (int) myStack.peek());
}

@Test
Expand All @@ -57,7 +57,7 @@ void testPopWithElements() {
myStack.push(40);
myStack.push(50);

Assertions.assertEquals(50, myStack.pop());
Assertions.assertEquals(50, (int) myStack.pop());

}

Expand Down
3 changes: 3 additions & 0 deletions src/test/java/com/sorts/CycleSortTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ void cycleSortIntegerTest() {
String[] sortedStr = new String[]{"Alan", "David", "Dennis", "Edward", "Ken", "Linus", "Robert"};
Assertions.assertArrayEquals(sortedStr, cycleSort.sort(unsortedStr));

Integer[] unsortedShortInt = new Integer[]{29, 11};
Integer[] sortedShortInt = new Integer[]{11, 29};
Assertions.assertArrayEquals(sortedShortInt, cycleSort.sort(unsortedShortInt));
}
}