Skip to content

Commit 45f01fe

Browse files
committed
Mention that Exc with equivalent elements is NP-hard (#233)
1 parent 4607db7 commit 45f01fe

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/Measures-of-disorder.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ $$
209209

210210
Computes the minimum number of exchanges required to sort $X$, which corresponds to $|X|$ minus the number of cycles in the sequence. A cycle corresponds to a number of elements in a sequence that need to be rotated to be in their sorted position; for example, let $\langle 2, 4, 0, 6, 3, 1, 5 \rangle$ be a sequence, the cycles are $\langle 0, 2 \rangle$ and $\langle 1, 3, 4, 5, 6 \rangle$ so $Exc(X) = |X| - 2 = 5$.
211211

212+
**Warning:** `probe::exc` generally returns a result higher than the minimum number of exchanges required to sort $X$ when it contains *equivalent elements*. This is because extending $Exc$ to *equivalent elements* is a NP-hard problem (see *One the Cost of Interchange Rearrangement in Strings* by Amir et al). The function does handle such elements in some simple cases, but not in the general case.
213+
212214
| Complexity | Memory | Iterators |
213215
| ----------- | ----------- | ------------- |
214216
| n log n | n | Forward |

0 commit comments

Comments
 (0)