Skip to content

Commit de4829a

Browse files
2.2-2 fix
Replaced j with i in line 17. This is because according to the picture, the outer for loop has the iterator i and not j. Thanks for maintaining such an awesome repo! :)
1 parent 48bfc1a commit de4829a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C02-Getting-Started/2.2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Consider sorting n numbers stored in array A by first finding the smallest eleme
1414
### `Answer`
1515
![pic](./repo/s2/1.png)
1616

17-
Loop invariant: at the start of each iteration of the outer for loop, the subarray A[1..j-1] consists of the j-1 smallest elements in the array A[1..n] and this subarray is in sorted order.
17+
Loop invariant: at the start of each iteration of the outer for loop, the subarray A[1..i-1] consists of the i-1 smallest elements in the array A[1..n] and this subarray is in sorted order.
1818

1919
After the first n-1 elements, the subarray A[1..n-1] contains the smallest n-1 elements, sorted, and therefore element A[n] must be the largest element
2020

0 commit comments

Comments
 (0)