最优可调整大小数组
Optimal resizable arrays
AI总结:
本文研究可调整大小数组的空间与时间最优权衡,提出用 N+O(N^{1/r}) 存储空间配合短暂临时空间实现 O(1) 访问和 O(r) 摊销增长收缩,并通过增长博弈证明该摊销下界最优。
摘要:
可调整大小数组是一种能够通过在其一端或两端添加或移除元素来增长和收缩的数组,同时仍支持在给定索引的情况下对数组中存储的每个元素进行常数时间访问。由于数组的大小(即其中元素的数量)随时间变化,对可调整大小数组进行空间高效维护需要动态内存管理。标准的倍增技术允许仅使用 O(N) 空间维护大小为 N 的数组,每次操作的摊销时间为 O(1),甚至最坏情况时间也为 O(1)。Sitarski 和 Brodnik 等人描述了更好的解决方案,仅使用 N+O(√N) 空间维护大小为 N 的可调整大小数组,且每次操作时间仍为 O(1)。Brodnik 等人给出了一个简单证明,表明这是最优的。我们区分了存储可调整大小数组和访问其元素所需的空间,以及在数组增长或收缩期间可能需要的临时空间。对于每个整数 r≥2,我们证明如果 N+O(N^{1-1/r}) 空间可以在增长和收缩操作期间短暂使用,那么 N+O(N^{1/r}) 空间足以存储和访问大小为 N 的数组。按索引访问元素的最坏情况时间为 O(1),而增长和收缩操作的摊销时间为 O(r)。通过对一个增长博弈的精确分析,我们证明对于使用仅 N+O(N^{1/r}) 空间存储数组的一大类数据结构中的任何数据结构,即使只允许增长和访问操作,增长操作的摊销成本也是 Ω(r)。除非 r=2,否则增长和收缩操作的时间无法做到最坏情况。
英文摘要:
A \emph{resizable array} is an array that can \emph{grow} and \emph{shrink} by the addition or removal of items from its end, or both its ends, while still supporting constant-time \emph{access} to each item stored in the array given its \emph{index}. Since the size of an array, i.e., the number of items in it, varies over time, space-efficient maintenance of a resizable array requires dynamic memory management. A standard doubling technique allows the maintenance of an array of size~$N$ using only $O(N)$ space, with $O(1)$ amortized time, or even $O(1)$ worst-case time, per operation. Sitarski and Brodnik et al.\ describe much better solutions that maintain a resizable array of size~$N$ using only $N+O(\sqrt{N})$ space, still with $O(1)$ time per operation. Brodnik et al.\ give a simple proof that this is best possible. We distinguish between the space needed for \emph{storing} a resizable array, and accessing its items, and the \emph{temporary} space that may be needed while growing or shrinking the array. For every integer $r\ge 2$, we show that $N+O(N^{1/r})$ space is sufficient for storing and accessing an array of size~$N$, if $N+O(N^{1-1/r})$ space can be used briefly during grow and shrink operations. Accessing an item by index takes $O(1)$ worst-case time while grow and shrink operations take $O(r)$ amortized time. Using an exact analysis of a \emph{growth game}, we show that for any data structure from a wide class of data structures that uses only $N+O(N^{1/r})$ space to store the array, the amortized cost of grow is $Ω(r)$, even if only grow and access operations are allowed. The time for grow and shrink operations cannot be made worst-case, unless $r=2$.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。