We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 997a49c commit 4e98a47Copy full SHA for 4e98a47
ch02/README.md
@@ -377,3 +377,10 @@ number of inversions = n(n - 1)/2
377
```cpp
378
T(n) = theta(number_of_inversions + n)
379
```
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