Recently, we worked on a project for routing quantum information,

if you're interested you can read the paper at~\cite{Bapat2020}.

Here, we will try to abstract away the underlying quantum operations and operate at a higher level of routing.

We will consider the path graph $P_n=(V,E)$ in this project,

\paragraph{The Problem:} We will consider the path graph $P_n=(V,E)$ in this project,

i.e., vertices $1,\dots,n$ connected as

\begin{tikzpicture}

\graph{ 1 -- 2 -- "$\dots$" -- n };

\end{tikzpicture}, which helps simplify the problem significantly.

We assign each node $i\in V$ a \emph{token}, with a destination $\pi(i)$ given by a permutation $\pi\colon V \to V$.

To get the token at node $i$, we define $t(i)$ as the token at node $i$ and,

in an abuse of notation, let $\pi(t(i))$ be the destination of that token.

in an abuse of notation, let $\pi(t(i))$ be the destination of that token. The goal is to route each token to its destination.

The goal is to route each token to its destination.

We can route tokens by performing \emph{reversals},

\paragraph{The Model:} We can route tokens by performing \emph{reversals},

which exchange locations of tokens.

A reversal $\rev{i,j}$, for $i,j \in V$ and $i\leq j$, performs transpositions $\prod_{k=0}^{(j-i)/2}

\begin{pmatrix} i+k & j-k \end{pmatrix}$ of the tokens.

It is possible to implement any permutation using several reversals,

e.g., one could order tokens starting from the token at node 1 by performing $\rev{1,\pi(t(1))}$,

$\rev{2,\pi(t(2))}$, etc.

We are interested in doing this in a \emph{time} that is minimal

because, in fact, each reversal needs an amount of time to be implemented%

Each reversal needs an amount of time to be implemented%

\footnote{The time is the number of swap gates that can be performed in the quantum model in the same amount of time.},

namely

\begin{equation}

c(n) \coloneqq\sqrt{{(n+1)^2} - p(n)} / 3\,,

\end{equation}

where $p(n)\coloneqq n \pmod{2}$ is the parity of $n$.

This is a bit of a mouthful to work with, so it may help to simply approximate this by $n/3$.

Additionally, we allow ourselves to perform reversals $\rev{i,j}$ and $\rev{k,l}$ with $i<j<k<l$ simultaneously,

thus only incurring the time cost once for two disjoint reversals.

This is a bit of a mouthful to work with, so it may help to simply approximate this by $(n+1)/3$.

\paragraph{Our Goals:} We are interested in routing any given permutation $\pi$ in a \emph{time} that is minimal. Note that reversals that do not overlap can be performed simultaneously, i.e. $\rev{i,j}$ and $\rev{k,l}$ with $i<j<k<l$ can be performed in parallel or in one layer of the circuit. The time for a single layer is the time of the slowest operation in that layer. Finally, the time taken to perform the full circuit is a sum of times for each layer in the circuit. So, we have a few goals in this project:

\begin{enumerate}

\item Design an algorithm (or algorithms!) that given a permutation $\pi$ as input, implements $\pi$ using weighted reversals on the path.

\item Give a bound on the runtime of the algorithm.

\item Compare with the best known algorithm called odd-even sort~\cite{Knuth1998}, which takes time $n-o(n)$. If we beat it, hooray!

\item If we cannot beat the odd-even sort, then we try to show a runtime lower bound of $n-o(n)$.

\end{enumerate}

\section{Warm-up}

Let's simplify the problem. Suppose you can only use neighboring nearest-neighbor reversals (or swaps) to permute tokens, and each swap takes time 1. What is the minimum time necessary to implement any permutation on the path this way?

Note the similarity with sorting. In bubble sort, you make neighboring comparisons and swap if the two neighbors are out of order. Sorting takes $O(n^2)$ operations to sort any list, but our time is measured not in operations but in circuit depth. It turns out that the fastes possible