Skip to content

Commit 7b1c328

Browse files
author
MK
committed
1 parent f3f2661 commit 7b1c328

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/main/java/com/sorts/CycleSort.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public <T extends Comparable<T>> T[] sort(T[] arr) {
1515
int count = 0;
1616

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

2020
// Initialize item as the starting point
2121
T item = arr[i];

src/test/java/com/dataStructures/StackTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void testPeekWithElements() {
3636
myStack.push(30);
3737
myStack.push(40);
3838

39-
Assertions.assertEquals(40, myStack.peek());
39+
Assertions.assertEquals(40, (int) myStack.peek());
4040
}
4141

4242
@Test
@@ -57,7 +57,7 @@ void testPopWithElements() {
5757
myStack.push(40);
5858
myStack.push(50);
5959

60-
Assertions.assertEquals(50, myStack.pop());
60+
Assertions.assertEquals(50, (int) myStack.pop());
6161

6262
}
6363

src/test/java/com/sorts/CycleSortTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ void cycleSortIntegerTest() {
3030
String[] sortedStr = new String[]{"Alan", "David", "Dennis", "Edward", "Ken", "Linus", "Robert"};
3131
Assertions.assertArrayEquals(sortedStr, cycleSort.sort(unsortedStr));
3232

33+
Integer[] unsortedShortInt = new Integer[]{29, 11};
34+
Integer[] sortedShortInt = new Integer[]{11, 29};
35+
Assertions.assertArrayEquals(sortedShortInt, cycleSort.sort(unsortedShortInt));
3336
}
3437
}

0 commit comments

Comments
 (0)