Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| courses:cs211:winter2018:journals:donohuem:chapter5 [2018/03/12 21:17] – donohuem | courses:cs211:winter2018:journals:donohuem:chapter5 [2018/03/12 21:39] (current) – [5.3 Counting Inversions] donohuem | ||
|---|---|---|---|
| Line 12: | Line 12: | ||
| ===== 5.3 Counting Inversions ===== | ===== 5.3 Counting Inversions ===== | ||
| + | The motivation of the problem is preference rankings. Suppose we wish to create an algorithm that compares the rankings of one individual to another' | ||
| + | |||
| + | Sort-and-Count(L) | ||
| + | if list L has one element | ||
| + | return 0 and the list L | ||
| + | | ||
| + | (iA, A) = Sort-and-Count(A) | ||
| + | (iB, B) = Sort-and-Count(B) | ||
| + | (i, L) = Merge-and-Count(A, | ||
| + | | ||
| + | | ||
| + | | ||
| + | Overall, the readability of this section is 7/10. | ||
