Download multi_radix_heap.tex from EncryptidSystems/Multi-Radix-Heap: direct link, hf CLI and curl.
- Browser
- Download file 25.1 kB
-
https://huggingface.co/spaces/EncryptidSystems/Multi-Radix-Heap/resolve/main/multi_radix_heap.tex
- Command line
-
hf download hf://spaces/EncryptidSystems/Multi-Radix-Heap/multi_radix_heap.tex
-
curl -L -o multi_radix_heap.tex https://huggingface.co/spaces/EncryptidSystems/Multi-Radix-Heap/resolve/main/multi_radix_heap.tex
25.1 kB
| \documentclass[11pt]{article} | |
| \usepackage[margin=1in]{geometry} | |
| \usepackage{amsmath,amssymb,amsthm} | |
| \usepackage{booktabs,xcolor} | |
| \usepackage{algorithm} | |
| \usepackage[noend]{algpseudocode} | |
| \usepackage[numbers,sort&compress]{natbib} | |
| \usepackage[colorlinks=true,linkcolor=blue!50!black,citecolor=blue!50!black,urlcolor=blue!50!black]{hyperref} | |
| \usepackage{enumitem} | |
| \setlist{nosep,leftmargin=*} | |
| \newtheorem{theorem}{Theorem} | |
| \newtheorem{lemma}{Lemma} | |
| \newtheorem{proposition}{Proposition} | |
| \newtheorem{corollary}{Corollary} | |
| \theoremstyle{definition} | |
| \newtheorem{definition}{Definition} | |
| \theoremstyle{remark} | |
| \newtheorem{remark}{Remark} | |
| \newcommand{\rmax}{r_{\max}} | |
| \newcommand{\lev}{\ell} | |
| \newcommand{\Loc}{\textsc{Locate}} | |
| \title{The Multi-Radix Heap:\\ A Mixed-Radix Monotone Priority Queue for Dijkstra's Algorithm} | |
| \author{Gregory Disney-Leugers\\ \small Encryptid Systems} | |
| \date{November 2026} | |
| \begin{document} | |
| \maketitle | |
| \begin{abstract} | |
| We define the multi-radix heap $\mathrm{MRH}(r;C)$, a monotone integer priority queue parameterised by an arbitrary tuple of radices $r=(r_0,\dots,r_{k-1})$ with $\prod_jr_j\ge C+1$. Keys are addressed by their mixed-radix digits with place values $\pi_0=1$, $\pi_{j+1}=\pi_jr_j$. A key is stored at the most significant digit in which it differs from the current frontier, and keys in the next block of size $\pi_k$ share a single overflow bucket. We prove that every item's level only decreases, and that each extract-min redistributes at most one bucket. It follows that any sequence of $n$ inserts, $m$ decrease-keys and at most $n$ extract-mins, with keys in a sliding window of width $C+1$, runs in $O(m+n(k+\rmax))$ time, where $\rmax=\max_jr_j$, using $O(n+\sum_jr_j)$ space. A refined bound weights each radix by the number of extract-mins that scan its level. Dijkstra's algorithm on a graph with $n$ vertices, $m$ arcs and integer lengths at most $C$ inherits the same bound. Binary radices give the $O(m+n\log C)$ bound of the one-level radix heap, uniform radices $\Delta=\Theta(\log C/\log\log C)$ give the $O(m+n\log C/\log\log C)$ bound of the two-level radix heap, and a single level of $C+1$ buckets is Dial's algorithm. A stored operation-count ablation of a reference implementation over eight radix tuples at $C=4095$ is reported. All eight runs reproduced binary-heap distances. The ablation shows that reordering the same radices changes the number of bucket scans by a factor of 7.2. | |
| \end{abstract} | |
| \section{Introduction} | |
| A priority queue is \emph{monotone} if successive extract-min operations return nondecreasing keys~\cite{thorup96,costa}. Dijkstra's algorithm~\cite{dijkstra} on a graph with non-negative arc lengths uses its queue monotonically: every key inserted or decreased after a vertex $u$ is settled is at least $d(u)$. When lengths are integers bounded by $C$, every such key also lies in the window $[d(u),d(u)+C]$, and bucket structures whose cost depends on $C$ rather than on comparison depth become available. | |
| Dial~\cite{dial} used $C+1$ unit-width buckets. Denardo and Fox~\cite{denardofox} introduced multi-level buckets with a uniform branching factor per level. Johnson~\cite{johnson} and Ahuja, Mehlhorn, Orlin and Tarjan~\cite{amot} developed radix heaps, whose one-level form uses $O(\log C)$ buckets of exponentially growing width and whose two-level form replaces powers of two by powers of a parameter $\Delta$. Cherkassky, Goldberg and Silverstein~\cite{cgs} combined multi-level buckets with heaps, and Goldberg and Silverstein~\cite{goldbergsilverstein} studied implementations. Practical libraries such as TLX~\cite{tlx} expose radix heaps with a single power-of-two radix. | |
| All of these structures fix one branching factor, or one sequence of bucket widths. We define a queue whose bucket hierarchy is induced by an \emph{arbitrary} radix tuple $(r_0,\dots,r_{k-1})$, possibly with unequal entries. We are not aware of a prior definition of a priority queue parameterised in this way. The structure is close in spirit to Denardo--Fox multi-level buckets. It differs in three respects: it allows level-dependent radices, it places keys relative to the frontier by their most significant differing digit, and it handles the sliding window with one overflow bucket rather than a wrap-around top level. | |
| \paragraph{Contributions.} | |
| \begin{enumerate} | |
| \item A precise definition of $\mathrm{MRH}(r;C)$ and its invariants (Section~\ref{sec:def}). It needs only $\prod_jr_j\ge C+1$. | |
| \item Correctness (Theorem~\ref{thm:correct}) and the amortised bound $O(m+n(k+\rmax))$, with a refined form $O(m+nk+\sum_jr_jE_j)$ in which $E_j$ counts the extract-mins that scan level $j$ (Theorem~\ref{thm:cost}). | |
| \item Dijkstra's algorithm on the multi-radix heap (Section~\ref{sec:dijkstra}): correctness, the running time $O(m+n(k+\rmax))$, and the radix-heap and Dial bounds as special cases. | |
| \item An operation-count ablation over eight radix tuples (Section~\ref{sec:exp}), and a description of two implementations (Section~\ref{sec:impl}). | |
| \end{enumerate} | |
| \section{Definition}\label{sec:def} | |
| \subsection{Mixed-radix addressing} | |
| \begin{definition}[radix tuple] | |
| Let $C\ge0$ be an integer. A \emph{radix tuple for $C$} is $r=(r_0,\dots,r_{k-1})$ with integers $r_j\ge2$ and | |
| \begin{equation}\label{eq:cover} | |
| \pi_k\ge C+1,\qquad\text{where}\quad \pi_0=1,\quad \pi_{j+1}=\pi_jr_j . | |
| \end{equation} | |
| We also admit the degenerate tuple $k=1$, $r_0=C+1$, which covers $C=0$. Write $\rmax=\max_jr_j$. | |
| \end{definition} | |
| For an integer $x\ge0$ define the digits and the block | |
| \begin{equation} | |
| \delta_j(x)=\Big\lfloor\frac{x}{\pi_j}\Big\rfloor\bmod r_j\quad(0\le j<k),\qquad \beta(x)=\Big\lfloor\frac{x}{\pi_k}\Big\rfloor, | |
| \end{equation} | |
| so that $x=\beta(x)\pi_k+\sum_{j<k}\delta_j(x)\pi_j$ with $0\le\delta_j(x)<r_j$. This is the mixed-radix numeral system with place values $\pi_j$. | |
| \begin{definition}[level and address] | |
| Fix a frontier $\mu\ge0$. For a key $\kappa\ge\mu$, its \emph{level} is | |
| \[ | |
| \lev_\mu(\kappa)=\begin{cases}k & \text{if }\beta(\kappa)\ne\beta(\mu),\\ \max\{j<k:\delta_j(\kappa)\ne\delta_j(\mu)\} & \text{if }\beta(\kappa)=\beta(\mu)\text{ and such }j\text{ exists},\\ 0&\text{if }\kappa=\mu.\end{cases} | |
| \] | |
| Its \emph{address} is $a_\mu(\kappa)=(\lev,\delta_\lev(\kappa))$ when $\lev=\lev_\mu(\kappa)<k$, and $a_\mu(\kappa)=(k,0)$ when $\lev_\mu(\kappa)=k$. | |
| \end{definition} | |
| \begin{definition}[multi-radix heap] | |
| $\mathrm{MRH}(r;C)$ stores items with integer keys and maintains a frontier $\mu$ (initially $0$, or any base key); buckets $B_j[t]$ for $0\le j<k$, $0\le t<r_j$, and one overflow bucket $B_k[0]$, each a doubly linked list; a count of items per level; and, for each item, a handle to its bucket. A configuration is \emph{valid} when | |
| \begin{itemize} | |
| \item[(I1)] every key satisfies $\mu\le K(x)\le\mu+C$, and | |
| \item[(I2)] every item $x$ lies in bucket $B_{a}$ with $a=a_\mu(K(x))$. | |
| \end{itemize} | |
| Operations are called under the \emph{window condition} (W): every key inserted, or set by decrease-key, lies in $[\mu,\mu+C]$ for the current $\mu$. | |
| \end{definition} | |
| Since $\mu$ never decreases (Theorem~\ref{thm:correct}), (W) implies the upper half of (I1) at all later times. | |
| \subsection{Order lemmas} | |
| \begin{lemma}[window]\label{lem:window} | |
| If $\mu\le\kappa\le\mu+C$ then $\beta(\kappa)\in\{\beta(\mu),\beta(\mu)+1\}$. | |
| \end{lemma} | |
| \begin{proof} | |
| $0\le\kappa-\mu\le C<\pi_k$ by \eqref{eq:cover}. | |
| \end{proof} | |
| \begin{lemma}[order]\label{lem:order} | |
| Let $\mu\le\kappa,\kappa'\le\mu+C$. | |
| \begin{enumerate} | |
| \item[(a)] If $\lev_\mu(\kappa)=j<k$ and $\kappa\ne\mu$, then $\delta_j(\kappa)>\delta_j(\mu)$. | |
| \item[(b)] If $\lev_\mu(\kappa)<\lev_\mu(\kappa')$, then $\kappa<\kappa'$. | |
| \item[(c)] If $\lev_\mu(\kappa)=\lev_\mu(\kappa')=j<k$ and $\delta_j(\kappa)<\delta_j(\kappa')$, then $\kappa<\kappa'$. | |
| \item[(d)] All keys with the same address at level $0$ are equal. | |
| \end{enumerate} | |
| \end{lemma} | |
| \begin{proof} | |
| Two numbers in the same block whose digits agree above position $j$ differ by $(\delta_j-\delta_j')\pi_j+\tau$ with $|\tau|<\pi_j$, where $\tau$ is the difference of their parts below $j$. So their order is the order of their $j$-th digits whenever those differ. | |
| (a) $\kappa$ and $\mu$ share the block and the digits above $j$, and $\kappa>\mu$, so $\delta_j(\kappa)>\delta_j(\mu)$. | |
| (b) Let $j'=\lev_\mu(\kappa')$. If $j'=k$, then $\beta(\kappa')=\beta(\mu)+1$ by Lemma~\ref{lem:window} while $\beta(\kappa)=\beta(\mu)$, so $\kappa<\kappa'$. If $j'<k$, both keys share the block and the digits above $j'$ with $\mu$, and $\delta_{j'}(\kappa)=\delta_{j'}(\mu)<\delta_{j'}(\kappa')$ by (a). | |
| (c) The keys share the block and the digits above $j$. | |
| (d) Such keys share the block and every digit. | |
| \end{proof} | |
| \begin{lemma}[monotone level]\label{lem:mono} | |
| If $\mu\le\kappa'\le\kappa\le\mu+C$, then $\lev_\mu(\kappa')\le\lev_\mu(\kappa)$. | |
| \end{lemma} | |
| \begin{proof} | |
| Otherwise Lemma~\ref{lem:order}(b) gives $\kappa<\kappa'$. | |
| \end{proof} | |
| By Lemma~\ref{lem:order}(a), in a valid configuration the buckets $B_j[t]$ with $t\le\delta_j(\mu)$ are empty, except $B_0[\delta_0(\mu)]$, which holds exactly the items with key $\mu$. | |
| \subsection{Operations} | |
| All digit computations are word operations; when every $\pi_j$ is a power of two they are shifts and masks. | |
| \paragraph{Locate.} $\Loc(\kappa,h)$ returns $a_\mu(\kappa)$, given the promise $\lev_\mu(\kappa)\le h$. If $h=k$ and $\beta(\kappa)\ne\beta(\mu)$, it returns $(k,0)$. Otherwise it compares $\delta_j(\kappa)$ with $\delta_j(\mu)$ for $j=\min(h,k-1),\dots,1$ and returns at the first difference; if there is none it returns $(0,\delta_0(\kappa))$. Its cost is $O(1+h-\lev_\mu(\kappa))$. | |
| \paragraph{Insert and decrease-key.} $\textsc{Insert}(x,\kappa)$ splices $x$ into $B_{\Loc(\kappa,k)}$. $\textsc{DecreaseKey}(x,\kappa')$, with $\mu\le\kappa'<K(x)$, unlinks $x$ from its level $j$ and splices it into $B_{\Loc(\kappa',j)}$, which is valid by Lemma~\ref{lem:mono}. | |
| \paragraph{Extract-min.} See Algorithm~\ref{alg:extract}. When the frontier bucket is empty, the least nonempty level $j^\ast$ and its least nonempty bucket $t^\ast$ hold the minimum. The frontier moves to that minimum, and only that bucket is redistributed. | |
| \begin{algorithm}[t] | |
| \caption{\textsc{ExtractMin} on $\mathrm{MRH}(r;C)$}\label{alg:extract} | |
| \begin{algorithmic}[1] | |
| \If{$B_0[\delta_0(\mu)]$ is empty} | |
| \State $j^\ast\gets$ least level with a nonzero count \Comment{$O(k)$} | |
| \If{$j^\ast=k$} $t^\ast\gets0$ | |
| \Else\ $t^\ast\gets$ least $t>\delta_{j^\ast}(\mu)$ with $B_{j^\ast}[t]$ nonempty \Comment{at most $r_{j^\ast}$ probes} | |
| \EndIf | |
| \State $\mu\gets\min\{K(y):y\in B_{j^\ast}[t^\ast]\}$ | |
| \If{$j^\ast\ge1$} | |
| \For{each $y$ in $B_{j^\ast}[t^\ast]$} | |
| \State move $y$ to $B_{\Loc(K(y),\,\min(j^\ast-1,k-1))}$ | |
| \EndFor | |
| \EndIf | |
| \EndIf | |
| \State remove any item $x$ from $B_0[\delta_0(\mu)]$ and \Return $(x,K(x))$ | |
| \end{algorithmic} | |
| \end{algorithm} | |
| \section{Correctness and cost}\label{sec:analysis} | |
| \begin{lemma}[frontier advance]\label{lem:advance} | |
| In a valid configuration with $B_0[\delta_0(\mu)]$ empty, let $j^\ast,t^\ast$ be as in Algorithm~\ref{alg:extract} and let $\mu'$ be the least key in $B_{j^\ast}[t^\ast]$. Then | |
| \begin{enumerate} | |
| \item[(i)] $\mu'$ is the least key in the heap; | |
| \item[(ii)] every item $x\notin B_{j^\ast}[t^\ast]$ satisfies $a_{\mu'}(K(x))=a_\mu(K(x))$; | |
| \item[(iii)] if $j^\ast\ge1$, every $y\in B_{j^\ast}[t^\ast]$ satisfies $\lev_{\mu'}(K(y))<j^\ast$; if $j^\ast=0$, every such $y$ has $K(y)=\mu'$ and address $(0,\delta_0(\mu'))$. | |
| \end{enumerate} | |
| \end{lemma} | |
| \begin{proof} | |
| (i) By Lemma~\ref{lem:order}(b), keys at levels above $j^\ast$ exceed keys at level $j^\ast$. By (c), keys in later buckets of level $j^\ast$ exceed keys in $B_{j^\ast}[t^\ast]$. The level-$k$ bucket is the only bucket of its level. | |
| (iii) If $j^\ast=k$, every key in $B_k[0]$ lies in block $\beta(\mu)+1$ (Lemma~\ref{lem:window}), as does $\mu'$, so their levels relative to $\mu'$ are below $k$. If $1\le j^\ast<k$, the keys of $B_{j^\ast}[t^\ast]$, including $\mu'$, share the block and all digits from $j^\ast$ upward, so they differ from $\mu'$ only below $j^\ast$. If $j^\ast=0$, Lemma~\ref{lem:order}(d) gives $K(y)=\mu'$. | |
| (ii) If $j^\ast=k$ there is no such $x$, since every lower level is empty. Let $j^\ast<k$, and let $x$ have address $(j_x,t_x)$ relative to $\mu$, with $j_x\ge j^\ast$. Relative to $\mu$, the new frontier $\mu'$ has the same block and the same digits above $j^\ast$, and $\delta_{j^\ast}(\mu')=t^\ast$. If $j_x=k$, then $\beta(K(x))\ne\beta(\mu)=\beta(\mu')$. If $j^\ast<j_x<k$, then $K(x)$ agrees with $\mu$, hence with $\mu'$, on the block and above $j_x$, and $\delta_{j_x}(K(x))\ne\delta_{j_x}(\mu)=\delta_{j_x}(\mu')$. If $j_x=j^\ast$, then $t_x\ne t^\ast=\delta_{j^\ast}(\mu')$, with agreement above. In each case the level and the digit are unchanged. | |
| \end{proof} | |
| \begin{theorem}[correctness]\label{thm:correct} | |
| Starting from an empty heap, under (W) every operation preserves (I1)--(I2), $\mu$ never decreases, and each extract-min returns an item of least key. Successive extracted keys are nondecreasing. | |
| \end{theorem} | |
| \begin{proof} | |
| Insert and decrease-key place the item at its address under (W) and Lemma~\ref{lem:mono}. In extract-min, if $B_0[\delta_0(\mu)]$ is nonempty its items have key $\mu$, which is minimal by (I1). Otherwise Lemma~\ref{lem:advance} shows that $\mu'$ is the minimum, so $\mu'\ge\mu$ and (I1) holds for $\mu'$. Items outside the redistributed bucket keep valid addresses. Redistributed items are placed by $\Loc$ with a valid promise. The item of key $\mu'$ lands in $B_0[\delta_0(\mu')]$, which is therefore nonempty when the last line runs. | |
| \end{proof} | |
| \begin{theorem}[amortised cost]\label{thm:cost} | |
| Consider any sequence on an initially empty $\mathrm{MRH}(r;C)$ with $n$ inserts, $m$ decrease-keys and at most $n$ extract-mins, satisfying (W). Let $E_j$ be the number of extract-mins with $j^\ast=j$, so $\sum_jE_j\le n$. The total time is | |
| \begin{equation}\label{eq:cost} | |
| O\Big(m+nk+\sum_{j<k}r_jE_j\Big)\;\subseteq\;O\big(m+n(k+\rmax)\big), | |
| \end{equation} | |
| and the space is $O(n+\sum_jr_j)$. | |
| \end{theorem} | |
| \begin{proof} | |
| \emph{Levels only decrease.} Decrease-key does not raise a level (Lemma~\ref{lem:mono}). A frontier advance leaves every other item's address unchanged and moves the redistributed items to strictly lower levels (Lemma~\ref{lem:advance}). Hence an item descends at most $k$ levels in total, and each redistribution of an item strictly lowers its level, so there are at most $nk$ redistribution moves. | |
| \emph{Placement.} An insert costs $O(k)$, which totals $O(nk)$. A decrease-key or a redistribution move from level $j$ to level $j'$ costs $O(1+j-j')$. Over an item's lifetime the terms $j-j'$ sum to at most $k$. So decrease-keys cost $O(m+nk)$ in total and redistributions $O(nk)$. Computing $\mu'$ costs $O(|B_{j^\ast}[t^\ast]|)$, which is charged to the moves when $j^\ast\ge1$; when $j^\ast=0$, Lemma~\ref{lem:order}(d) lets any item supply $\mu'$. | |
| \emph{Scanning.} Each extract-min that finds $B_0[\delta_0(\mu)]$ empty spends $O(k)$ finding $j^\ast$ from the counts, probes at most $r_{j^\ast}$ buckets (one if $j^\ast=k$), and redistributes one bucket. Summing over extract-mins gives $O(nk+\sum_jr_jE_j)$. Space comes from $\sum_jr_j+1$ bucket heads, $k+1$ counts and $O(1)$ words per item. | |
| \end{proof} | |
| Redistributing only one bucket per extract-min matters for the bound. It replaces the per-level sum $\sum_jr_j$ of a naive analysis by the single largest radix. | |
| \begin{proposition}[best tuple for a given depth]\label{prop:tuple} | |
| For fixed $k$, every radix tuple for $C$ has $\rmax\ge\lceil(C+1)^{1/k}\rceil$, and the uniform tuple $r_j=\lceil(C+1)^{1/k}\rceil$ attains it. | |
| \end{proposition} | |
| \begin{proof} | |
| $\rmax^k\ge\prod_jr_j\ge C+1$. | |
| \end{proof} | |
| Unequal radices therefore do not improve the worst-case bound \eqref{eq:cost} at a given depth. What they allow is two things. First, $\pi_k=C+1$ exactly, whenever $C+1$ factors into $k$ parts of size at least two. Second, radices can be matched to how often each level is scanned, through the weights $E_j$ in \eqref{eq:cost}. | |
| \section{Dijkstra's algorithm}\label{sec:dijkstra} | |
| Let $G=(V,E)$ be a directed graph with $|V|=n$, $|E|=m$, a source $s$ and lengths $\ell:E\to\{0,1,\dots,C\}$. | |
| \begin{algorithm}[t] | |
| \caption{Dijkstra's algorithm on $\mathrm{MRH}(r;C)$}\label{alg:dijkstra} | |
| \begin{algorithmic}[1] | |
| \State $d(s)\gets0$; $d(v)\gets\infty$ for $v\ne s$; $H\gets\mathrm{MRH}(r;C)$ with $\mu=0$; $H.\textsc{Insert}(s,0)$ | |
| \While{$H$ is nonempty} | |
| \State $(u,d(u))\gets H.\textsc{ExtractMin}()$ | |
| \For{each arc $(u,v)\in E$ with $v$ unsettled} | |
| \State $\delta\gets d(u)+\ell(u,v)$ | |
| \If{$d(v)=\infty$} $d(v)\gets\delta$; $H.\textsc{Insert}(v,\delta)$ | |
| \ElsIf{$\delta<d(v)$} $d(v)\gets\delta$; $H.\textsc{DecreaseKey}(v,\delta)$ | |
| \EndIf | |
| \EndFor | |
| \EndWhile | |
| \State \Return $d$ | |
| \end{algorithmic} | |
| \end{algorithm} | |
| \begin{proposition}[monotone use]\label{prop:window} | |
| Every insert and decrease-key issued by Algorithm~\ref{alg:dijkstra} satisfies (W). | |
| \end{proposition} | |
| \begin{proof} | |
| The first insert has key $0=\mu$. Every other call is made while relaxing the arcs of the vertex $u$ just extracted, when $\mu=d(u)$, and has key $d(u)+\ell(u,v)\in[\mu,\mu+C]$. | |
| \end{proof} | |
| \begin{theorem}[multi-radix Dijkstra]\label{thm:dijkstra} | |
| Algorithm~\ref{alg:dijkstra} returns $d(v)=\mathrm{dist}_G(s,v)$ for every $v$, in time $O(m+n(k+\rmax))$ and space $O(n+\sum_jr_j)$ beyond the graph. | |
| \end{theorem} | |
| \begin{proof} | |
| Dijkstra's algorithm is correct with any priority queue that implements insert, decrease-key and extract-min correctly on the keys it presents. By Proposition~\ref{prop:window} and Theorem~\ref{thm:correct}, $\mathrm{MRH}(r;C)$ does so. Each vertex is inserted and extracted at most once, and each arc causes at most one decrease-key, when its tail is extracted. Theorem~\ref{thm:cost} with $O(n+m)$ for traversal gives the bound. | |
| \end{proof} | |
| \begin{corollary}[special cases]\label{cor:special} | |
| \begin{enumerate} | |
| \item[(i)] \emph{Binary radices}, $r=(2,\dots,2)$ with $k=\lceil\log_2(C+1)\rceil$: $O(m+n\log C)$, the bound of the one-level radix heap~\cite{amot}. | |
| \item[(ii)] \emph{Uniform radices} $\Delta$ with $k=\lceil\log_\Delta(C+1)\rceil$: $O(m+n(\log_\Delta C+\Delta))$. With $\Delta=\Theta(\log C/\log\log C)$, $\log\Delta=\Theta(\log\log C)$, so this is $O(m+n\log C/\log\log C)$, the bound of the two-level radix heap~\cite{amot}. | |
| \item[(iii)] \emph{One level}, $k=1$ and $r_0=C+1$: the structure is Dial's array of $C+1$ unit buckets~\cite{dial}, and the bound is $O(m+nC)$. | |
| \end{enumerate} | |
| \end{corollary} | |
| Faster asymptotic bounds for integer-weighted shortest paths are known on the word RAM~\cite{thorup96,thorup04}, and the two-level radix heap with Fibonacci heaps improves (ii)~\cite{amot}. The multi-radix heap is aimed at a simple, array-based structure with an explicit radix dial. | |
| \section{Operation-count ablation}\label{sec:exp} | |
| We report a stored ablation produced by the reference implementation described in Section~\ref{sec:impl}. Its result file is \texttt{radix\_ablation.json} and its script is \texttt{test\_mrh.py}. The graph is a random directed graph with $n=5{,}000$ vertices and $m=30{,}000$ arcs: a spanning path plus uniformly random arcs, with lengths uniform in $\{0,\dots,4095\}$. Here $C=4095$, so every tuple has $\pi_k=4096$. For each of eight tuples, the script runs Dijkstra from vertex $0$ and asserts that the distances equal those of a binary-heap Dijkstra before writing the file. All eight runs passed. Three counters are recorded: \emph{locate} (digit comparisons during placement), \emph{scans} (bucket probes during extract-min) and \emph{moves} (redistributed items). These are operation counts, not times. This implementation locates every key from the top level downward, so its locate count is at most $k+1$ per placement rather than the descent-proportional cost used in Theorem~\ref{thm:cost}. | |
| \begin{center}\small | |
| \begin{tabular}{lrrrrrrr}\toprule | |
| Radices & $k$ & $\sum_jr_j$ & $\rmax$ & locate & scans & moves & total\\\midrule | |
| $(2)^{12}$ & 12 & 24 & 2 & 237,631 & 5,944 & 27,714 & 271,289\\ | |
| $(4)^{6}$ & 6 & 24 & 4 & 106,414 & 9,150 & 21,907 & 137,471\\ | |
| $(8)^{4}$ & 4 & 32 & 8 & 65,347 & 15,396 & 17,797 & 98,540\\ | |
| $(16)^{3}$ & 3 & 48 & 16 & 46,324 & 27,511 & 14,895 & 88,730\\ | |
| $(64)^{2}$ & 2 & 128 & 64 & 28,845 & 99,825 & 11,089 & 139,759\\ | |
| $(2,4,8,64)$ & 4 & 78 & 64 & 54,723 & 13,365 & 15,643 & 83,731\\ | |
| $(64,8,4,2)$ & 4 & 78 & 64 & 65,283 & 96,095 & 15,524 & 176,902\\ | |
| $(4096)$, Dial & 1 & 4,096 & 4,096 & 14,343 & 5,983,094 & 6,415 & 6,003,852\\\bottomrule | |
| \end{tabular} | |
| \end{center} | |
| Among uniform tuples, locate and move counts fall and scan counts rise as $k$ decreases and $\rmax$ grows, which is the trade-off in \eqref{eq:cost}. The lowest total, 83,731, is for the mixed tuple $(2,4,8,64)$. The tuples $(2,4,8,64)$ and $(64,8,4,2)$ have the same radices in opposite order. Their scan counts differ by a factor of 7.2 (13,365 against 96,095), although their worst-case bounds are identical. The refined bound $\sum_jr_jE_j$ predicts a difference of this kind, since it weights each radix by how often its level is scanned. The script did not record the $E_j$, so this explanation is not tested here. The Dial row's 5,983,094 scans lie within the bound $n\,\rmax=20{,}480{,}000$. | |
| \section{Implementations}\label{sec:impl} | |
| \paragraph{Reference implementation.} The Python implementation \texttt{mrh.py} used in Section~\ref{sec:exp} follows Section~\ref{sec:def}. It has digit-based placement relative to $\mu$, one overflow bucket, per-level counts, and one redistributed bucket per extract-min. It differs in two inessential ways. It locates from the top level, and it scans a level from bucket $0$ instead of from $\delta_{j^\ast}(\mu)+1$. Those buckets are empty by Lemma~\ref{lem:order}(a), so the scan cost changes by at most a constant factor. With top-down location, decrease-keys cost $O(k)$ each and redistribution moves $O(k)$ each, so its worst-case bound is $O(mk+nk^2+n\rmax)$. | |
| \paragraph{The \texttt{gptrun} implementation.} The Go implementation in \texttt{gptrun}~\cite{gptrun} uses explicit level bounds $L_j$ and active indices in the style of Denardo--Fox buckets, with a top block $[L_{k-1},L_{k-1}+\pi_k)$. When an inserted key falls beyond the top block, it re-files every item relative to $\mu$ (``rebase''). This is correct under \eqref{eq:cover}, but Theorem~\ref{thm:cost} does not cover it. | |
| \begin{remark}[rebasing can be quadratic] | |
| Let $\pi_k=C+1$ and $C\ge n$. Take a path $v_0\to v_1\to\dots\to v_t$ with unit lengths, and an arc of length $C$ from each $v_i$ to a fresh vertex $w_i$. Settling $v_i$ sets $\mu=i$ and inserts $w_i$ with key $i+C$. The previous rebase set $L_{k-1}=i-1$, so the key exceeds the top block and triggers a rebase, which re-files the $\Theta(i)$ vertices $w_0,\dots,w_{i-1}$ still in the queue. The total rebasing work is $\Theta(t^2)=\Theta(n^2)$. The overflow bucket of Section~\ref{sec:def} avoids this. | |
| \end{remark} | |
| \section{Limitations} | |
| \begin{itemize} | |
| \item The analysis is amortised over a sequence that starts empty and satisfies the window condition (W). The heap is not a general-purpose priority queue. | |
| \item Digit extraction is assumed to take $O(1)$ time. For radices that are not powers of two this needs division by the place values. | |
| \item The ablation is one graph family at one $C$, and it reports operation counts from an implementation with top-down location, not wall-clock times. We make no claim about practical speed relative to other queues. | |
| \item Unequal radices do not improve the worst-case bound at fixed depth (Proposition~\ref{prop:tuple}). A rule for choosing radices from the level weights $E_j$ is left open. | |
| \end{itemize} | |
| \section{Related structures} | |
| \begin{center}\small | |
| \begin{tabular}{p{0.24\linewidth}p{0.2\linewidth}p{0.47\linewidth}}\toprule | |
| Structure & Key model & Relation to MRH\\\midrule | |
| Binary / $d$-ary heap & comparisons & No buckets; $\Theta(\log_dn)$ per operation.\\ | |
| Fibonacci heap~\cite{fredmantarjan} & comparisons & $O(1)$ amortised insert and decrease-key, $O(\log n)$ extract-min; no radix geometry.\\ | |
| van Emde Boas tree~\cite{veb} & integers in $[0,U)$ & Recursive universe reduction, $O(\log\log U)$ per operation.\\ | |
| Dial buckets~\cite{dial} & monotone integers & The one-level MRH with $r_0=C+1$.\\ | |
| Denardo--Fox buckets~\cite{denardofox} & monotone integers & Uniform branching per level; MRH allows unequal radices and uses frontier-relative placement with an overflow bucket.\\ | |
| Radix heaps~\cite{johnson,amot} & monotone integers & One sequence of widths (powers of $2$ or $\Delta$); their bounds are recovered by binary and uniform tuples (Corollary~\ref{cor:special}).\\ | |
| Hot queues~\cite{cgs} & monotone integers & Multi-level buckets combined with a heap.\\ | |
| Soft heap~\cite{chazelle} & comparisons & Deliberate key corruption; unrelated.\\\bottomrule | |
| \end{tabular} | |
| \end{center} | |
| \bibliographystyle{unsrtnat} | |
| \bibliography{refs} | |
| \end{document} | |