Skip to content

Commit 844bf24

Browse files
committed
Add a visual explanation of the measure of disorder Osc
1 parent 2b69ba2 commit 844bf24

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ Libraries*](https://arxiv.org/abs/1505.01962).
231231
* The algorithm behind `utility::quicksort_adversary` is a fairly straightforward adaptation of the
232232
one provided by M. D. McIlroy in [*A Killer Adversary for Quicksort*](https://www.cs.dartmouth.edu/~doug/mdmspe.pdf).
233233

234-
* The algorithm used by [`utility::check_strict_weak_ordering`][utility-check-strict-weak-ordering] is a reimplementation of the one desribed in the README file of danlark1's [quadratic_strict_weak_ordering project](https://github.com/danlark1/quadratic_strict_weak_ordering).
234+
* The algorithm used by [`utility::check_strict_weak_ordering`][utility-check-strict-weak-ordering] is a reimplementation of the one desribed in the README file of Danila Kutenin's [quadratic_strict_weak_ordering project](https://github.com/danlark1/quadratic_strict_weak_ordering).
235235

236236
* The test suite reimplements random number algorithms originally found in the following places:
237237
- [xoshiro256\*\*](https://prng.di.unimi.it/)

docs/Measures-of-disorder.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ The measure of disorder is slightly different from its original description in [
332332

333333
Computes the *Oscillation* measure described by C. Levcopoulos and O. Petersson in *Adaptive Heapsort*, using an algorithm devised by J. Nehring.
334334

335+
Let $\lvert \lvert \mathit{Cross}(x_i) \rvert \rvert$ be the number of links between adjacent pairs that "cross" the value $x_i$. We define the oscillation measure as $\mathit{Osc}(X) = \sum_{i=0}^{\lvert X \rvert - 1} \lvert \lvert \mathit{Cross}(x_i) \rvert \rvert$.
336+
337+
![Plot of Cross(x_5) over the sequence 6, 3, 9, 8, 4, 7, 1, 10](images/measures-of-disorder-osc-cross.png)
338+
339+
In the illustration above, we can see that a horizontal line drawn from $x_5$ crosses three pairs of adjacent elements in the geometrical representation of the sequence $X = \langle 6, 3, 9, 8, 4, 7, 1, 10 \rangle$. Thus $\lvert \lvert \mathit{Cross}(x_5) \rvert \rvert = 3$. In this example, we have $\mathit{Osc(X) = 17}$.
340+
335341
| Complexity | Memory | Iterators | Monotonic |
336342
| ----------- | ----------- | ------------- | --------- |
337343
| n log n | n | Forward | No |
7.16 KB
Loading
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
\documentclass[margin=0.5cm]{standalone}
2+
\usepackage{tikz}
3+
\pagestyle{empty}
4+
5+
\begin{document}
6+
\begin{tikzpicture}
7+
8+
\draw[thin,->] (-0.25,0) -- (8,0) node[right] {$pos$};
9+
\draw[thin,->] (0,-0.25) -- (0,6) node[above] {$val$};
10+
11+
% ticks
12+
\foreach \x [count=\xi starting from 0] in {1,2,3,4,5,6,7}{
13+
\draw (\x,2pt) -- (\x,-2pt);
14+
\ifodd\xi
15+
\node[anchor=north] at (\x,0) {$\x$};
16+
\fi
17+
}
18+
\foreach \x [count=\xi starting from 0] in {1,2,3,4,5,6,7,8,9,10,11}{
19+
\draw (2pt,\x/2) -- (-2pt,\x/2);
20+
\ifodd\xi
21+
\node[anchor=east] at (0,\x/2) {$\x$};
22+
\fi
23+
}
24+
25+
% points
26+
\foreach \y [count=\x] in {
27+
6, 3, 9, 8, 4, 7, 1, 10
28+
}{
29+
\fill (\x-1,\y/2) circle (2pt);
30+
}
31+
32+
\tikzset{every edge/.append style = {gray}};
33+
34+
\path[every node/.style={font=\sffamily\small}]
35+
(0,6/2) edge (1,3/2)
36+
(1,3/2) edge (2,9/2)
37+
(2,9/2) edge (3,8/2)
38+
(3,8/2) edge (4,4/2)
39+
(4,4/2) edge (5,7/2)
40+
(5,7/2) edge (6,1/2)
41+
(6,1/2) edge (7,10/2);
42+
43+
44+
\tikzset{every edge/.append style = {dashed,gray}};
45+
46+
\path[every node/.style={font=\sffamily\small}]
47+
(0,7/2) edge (8,7/2);
48+
49+
\end{tikzpicture}
50+
\end{document}

0 commit comments

Comments
 (0)