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.
翻译:假设输入为由Elias gamma编码表示的k个数的N比特序列S。我们在字大小为Ω(log N)比特的字RAM模型中提出了针对S进行排序、密集排名和竞争排名的空间高效算法。我们的算法运行时间为O(k + N/log N),并使用O(N)比特。排序算法以排序顺序返回给定数字,并存储在N比特的位向量中,而我们的排名算法构建的数据结构允许我们随后在常数时间内返回S中每个数x的密集/竞争排名。对于x ∈ ℕ且x > N的数,我们需要x的位置p_x作为密集/竞争排名数据结构的输入。作为上述算法的应用,我们给出了一种树同构算法,该算法在n节点树上运行时间为O(n)并使用O(n)比特。最后,我们将树的同构结果推广到森林和外平面图,同时保持O(n)比特的空间使用。此前针对树、森林和外平面图同构的最佳线性时间算法均使用Θ(n log n)比特。