File tree Expand file tree Collapse file tree 3 files changed +5
-3
lines changed
src/algorithms/sorting/cyclicSort/simple Expand file tree Collapse file tree 3 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 9
9
<sourceFolder url =" file://$MODULE_DIR$/algorithms/sorting" isTestSource =" false" />
10
10
<sourceFolder url =" file://$MODULE_DIR$/src" isTestSource =" false" />
11
11
<sourceFolder url =" file://$MODULE_DIR$/algorithms/patternFinding" isTestSource =" false" />
12
+ <sourceFolder url =" file://$MODULE_DIR$/test" isTestSource =" false" />
12
13
<excludePattern pattern =" *README.md" />
13
14
</content >
14
15
<orderEntry type =" inheritedJdk" />
Original file line number Diff line number Diff line change 9
9
<sourceFolder url =" file://$MODULE_DIR$/algorithms/sorting" isTestSource =" false" />
10
10
<sourceFolder url =" file://$MODULE_DIR$/src" isTestSource =" false" />
11
11
<sourceFolder url =" file://$MODULE_DIR$/algorithms/patternFinding" isTestSource =" false" />
12
+ <sourceFolder url =" file://$MODULE_DIR$/test" isTestSource =" false" />
12
13
<excludePattern pattern =" *README.md" />
13
14
</content >
14
15
<orderEntry type =" inheritedJdk" />
Original file line number Diff line number Diff line change @@ -38,12 +38,12 @@ public static void sort(int[] arr) {
38
38
while (curr < arr .length ) { // iterate until the end of the array
39
39
int ele = arr [curr ]; // encounter an element that may not be in its correct position
40
40
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
42
42
int tmp = arr [ele ]; // go to the correct position of ele
43
43
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
45
45
} 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
47
47
}
48
48
}
49
49
}
You can’t perform that action at this time.
0 commit comments