Skip to content

Commit 2dc1265

Browse files
divide and conquer and brute force algorithms for array-inversions counting
1 parent 32abbf6 commit 2dc1265

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: divide_and_conquer/inversions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def _count_cross_inversions(P, Q):
9393
i = j = num_inversion = 0
9494
while i < len(P) and j < len(Q):
9595
if P[i] > Q[j]:
96-
# if P[1] is > Q[j], then P[k] for all k > i, P[K] > Q[j]
97-
# and therefore are inversions. This claim emerges from the
96+
# if P[1] > Q[j], then P[k] > Q[k] for all i < k <= len(P)
97+
# These are all inversions. The claim emerges from the
9898
# property that P is sorted.
9999
num_inversion += (len(P) - i)
100100
R.append(Q[j])

0 commit comments

Comments
 (0)