You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let the number of inputs be $N$ and the number of comparators be $L$.
It is well known that the 0-1 principle allows the verification of networks with a computational complexity of $O(L\cdot 2^N)$,
With an ingenious implementation, this can be achieved with a computational complexity of $O(L\cdot\varphi^N)$, where $\varphi$ is the golden number $\varphi=\dfrac{1+\sqrt{5}}{2}\simeq 1.618$.
This is due to the fact that the number of branches in the search tree is a Fibonacci number $\mathrm{Fib}(N+1)=\left\lfloor\dfrac{\varphi^{N+1}}{\sqrt{5}}+\dfrac{1}{2}\right\rfloor$.
The following is a paper (in Japanese) describing this algorithm:
Hisayasu Kuroda. (1997). A proposal of Gap Decrease Sorting Network. Trans.IPS.Japan, vol.38, no.3, p.381-389. http://id.nii.ac.jp/1001/00013442/
Hisayasu Kuroda, (1994). A Study of Sorting networks -Gap Decrease Sort-. IPSJ SIG Technical Reports, vol.1994, no.108(1994-HPC-054), p.53-60. http://id.nii.ac.jp/1001/00029885/
Let the number of inputs be$N$ and the number of comparators be $L$ .
It is well known that the 0-1 principle allows the verification of networks with a computational complexity of$O(L\cdot 2^N)$ ,
With an ingenious implementation, this can be achieved with a computational complexity of$O(L\cdot\varphi^N)$ , where $\varphi$ is the golden number $\varphi=\dfrac{1+\sqrt{5}}{2}\simeq 1.618$ .
This is due to the fact that the number of branches in the search tree is a Fibonacci number$\mathrm{Fib}(N+1)=\left\lfloor\dfrac{\varphi^{N+1}}{\sqrt{5}}+\dfrac{1}{2}\right\rfloor$ .
The following is a paper (in Japanese) describing this algorithm:
Here is an example implementation in Python:
See also the probrem of competition programming "Verification of Sorting Network" (in Japanese):
This is a demonstration video of a fast N=40 verification using multi-threading. (Executed on Tauri)
sortingnetwork-tauri-app.2025-03-05.23-54-31.mp4
Note, however, that this method is useful when$N$ is large, but when $N$ is small, the $O(L\cdot 2^N)$ method with SIMD is faster.