Assume that an $N$-bit sequence $S$ of $k$ numbers encoded as Elias gamma codes is given as input. We present space-efficient algorithms for sorting, dense ranking and competitive ranking on $S$ in the word RAM model with word size $\Omega(\log N)$ bits. Our algorithms run in $O(k + \frac{N}{\log N})$ time and use $O(N)$ bits. The sorting algorithm returns the given numbers in sorted order, stored within a bit-vector of $N$ bits, whereas our ranking algorithms construct data structures that allow us subsequently to return the dense/competitive rank of each number $x$ in $S$ in constant time. For numbers $x \in \mathbb{N}$ with $x > N$ we require the position $p_x$ of $x$ as the input for our dense-/competitive-rank data structure. As an application of our algorithms above we give an algorithm for tree isomorphism, which runs in $O(n)$ time and uses $O(n)$ bits on $n$-node trees. Finally, we generalize our result for tree isomorphism to forests and outerplanar graphs, while maintaining a space-usage of $O(n)$ bits. The previous best linear-time algorithms for trees, forests and outerplanar graph isomorphism all use $\Theta(n \log n)$ bits.
翻译:假设输入为一个由 $k$ 个数字编码为 Elias gamma 码组成的 $N$ 比特序列 $S$。我们在字长为 $\Omega(\log N)$ 比特的字 RAM 模型中,提出了对 $S$ 进行排序、密集排名和竞争排名的空间高效算法。我们的算法在 $O(k + \frac{N}{\log N})$ 时间内运行,并使用 $O(N)$ 比特空间。排序算法返回按排序顺序排列的给定数字,存储在一个 $N$ 比特的位向量中;而我们的排名算法则构建数据结构,使得我们随后能够在常数时间内返回 $S$ 中每个数字 $x$ 的密集/竞争排名。对于满足 $x > N$ 的数字 $x \in \mathbb{N}$,我们需要将 $x$ 的位置 $p_x$ 作为密集/竞争排名数据结构的输入。作为上述算法的应用,我们给出了一种树同构算法,该算法在 $n$ 个节点的树上以 $O(n)$ 时间运行,并使用 $O(n)$ 比特空间。最后,我们将树同构的结果推广到森林和外平面图,同时保持 $O(n)$ 比特的空间使用。先前针对树、森林和外平面图同构的最佳线性时间算法均使用 $\Theta(n \log n)$ 比特空间。