Skip to content

Commit d0f41ef

Browse files
committed
Fix some typo in cyclic sort docs
1 parent 732edd5 commit d0f41ef

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

out/production/scripts/scripts.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<sourceFolder url="file://$MODULE_DIR$/algorithms/sorting" isTestSource="false" />
1010
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
1111
<sourceFolder url="file://$MODULE_DIR$/algorithms/patternFinding" isTestSource="false" />
12+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="false" />
1213
<excludePattern pattern="*README.md" />
1314
</content>
1415
<orderEntry type="inheritedJdk" />

scripts/scripts.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<sourceFolder url="file://$MODULE_DIR$/algorithms/sorting" isTestSource="false" />
1010
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
1111
<sourceFolder url="file://$MODULE_DIR$/algorithms/patternFinding" isTestSource="false" />
12+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="false" />
1213
<excludePattern pattern="*README.md" />
1314
</content>
1415
<orderEntry type="inheritedJdk" />

src/algorithms/sorting/cyclicSort/simple/CyclicSort.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public static void sort(int[] arr) {
3838
while (curr < arr.length) { // iterate until the end of the array
3939
int ele = arr[curr]; // encounter an element that may not be in its correct position
4040
assert ele >= 0 && ele < arr.length : "Input array should only have integers from 0 to n-1 (inclusive)";
41-
if (ele != curr) { // verified that it is indeed not the correct element to be placed at this ith position
41+
if (ele != curr) { // verified that it is indeed not the correct element to be placed at this curr position
4242
int tmp = arr[ele]; // go to the correct position of ele
4343
arr[ele] = ele; // do a swap
44-
arr[curr] = tmp; // note that curr isn't incremented because we haven't yet place the correct element
44+
arr[curr] = tmp; // note that curr isn't incremented because we haven't yet placed the correct element
4545
} else {
46-
curr += 1; // we found the correct element to be placed pos curr, which in this example, is itself
46+
curr += 1; // we found the correct element to be placed at pos curr, which in this example, is itself
4747
}
4848
}
4949
}

0 commit comments

Comments
 (0)