Measure sequence disorder with fast, precise inversion analysis. Track parity, density, and sorting progress instantly. Graphs and metrics make sequence patterns easier to inspect.
Enter numbers separated by commas, spaces, semicolons, pipes, or line breaks.
| Sequence | Length | Inversion Count | Maximum Inversions | Parity | Sortedness |
|---|---|---|---|---|---|
| 1, 2, 3, 4 | 4 | 0 | 6 | Even | 100% |
| 3, 1, 2 | 3 | 2 | 3 | Even | 33.33% |
| 4, 3, 2, 1 | 4 | 6 | 6 | Even | 0% |
Inversion definition: An inversion is any pair of indices (i, j) such that i < j and ai > aj.
Inversion count: I(A) = |{(i, j) : i < j and ai > aj}|
Maximum inversions: n(n - 1) / 2 for a sequence of length n
Inversion ratio: I(A) / (n(n - 1) / 2)
Sortedness percentage: (1 - inversion ratio) × 100
Method: This calculator uses a merge-sort-based counting method for the main total, which runs in about O(n log n) time.
It measures how many index pairs are out of ascending order. A larger count means the sequence is more disordered relative to its sorted form.
No. This calculator uses a strict comparison. A pair counts only when the left value is greater than the right value.
Inversion count captures total disorder, not the exact placement of every mismatch. Different layouts can therefore produce the same overall total.
Parity tells whether the inversion count is even or odd. It is useful in permutation theory, determinant signs, and puzzle solvability checks.
That value equals the number of unique index pairs in the sequence. A reversed sequence puts every pair out of order, so all pairs become inversions.
It is a normalized score derived from the inversion ratio. Higher percentages mean the sequence is closer to ascending order.
Large sequences can contain many inversion pairs. Limiting the preview keeps the page readable while still showing representative disorder examples.
Yes. Brute force checks every pair directly. Merge-sort counting is much faster on larger inputs because it reduces the work to about n log n.
Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.