Skip to content

Commit 4e98a47

Browse files
committed
Update README.md
1 parent 997a49c commit 4e98a47

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ch02/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,10 @@ number of inversions = n(n - 1)/2
377377
```cpp
378378
T(n) = theta(number_of_inversions + n)
379379
```
380+
* Algorithm to find inversions in theta(n(lg(n))):
381+
```cpp
382+
Modify Merge-Sort as following:
383+
1 Pass count as a reference or a pointer into procedure Merge and Merge-Sort
384+
2 add statement : count += n1 - i into Merge between line 16 and line 17
385+
```
386+
* code : `find_inversions.hpp` and `test_find_inversions.cpp`.

0 commit comments

Comments
 (0)