10

Background:

In this question we care only about worst-case running-time.

Array and (doubly) linked lists can be used to keep a list of items and implement the vector abstract data type. Consider the following three operations:

  • $Location(i)$: returns a pointer to the $i$th item in the list of items in the array.
  • $Insert(k,x)$: insert the item $k$ in the list after the item pointed to by $x$.
  • $Delete(x)$: remove the item in the list pointed to by $x$.

The main operation that an array provides is location which can be computed in constant time. However delete and insert are inefficient.

On the other hand, in a doubly linked list, it is easy to perform insert and delete in constant time, but location is inefficient.

Questions:

Can there be a data structure to store a list of items where all three operations are $O(1)$? If not, what is the best worst-case running-time that we can achieve for all operations simultaneously?

Note that a balanced binary search tree like red-black trees augmented with size of subtrees would give $O(\lg n)$, is it possible to do better? Do we know a non-trivial lower-bound for this problem?

Kaveh
  • 22,231
  • 4
  • 51
  • 111
  • ps: it seems to me that an adversary argument shows that these cannot be done $O(1)$ simultaneously. I am not posting it because I feel that it is not an optimal lower-bound and there should be improvements. References on the problem would also be interesting. – Kaveh Feb 26 '13 at 01:14
  • 1
    I wonder if a precise answer to this question requires a more precise definition of the model of computation. For instance, in the operation $Location(i)$, $i$ must be of size $\log n$ in general, so we must be making some assumption to be able to say that $Location(i)$ is $O(1)$ for an array. – usul Feb 26 '13 at 01:27
  • 1
    @usul, assume RAM model if you need. – Kaveh Feb 26 '13 at 01:33
  • Am I right in my understanding that the RAM model requires $\log i$ time to access element $i$ in an array? – usul Feb 26 '13 at 05:44
  • 1
    @usul, no, it's constant time AFAIK. – Kaveh Feb 26 '13 at 06:15
  • A linear list with $k$ additional pointers kept in an array has constant insertion and deletion, but speeds up search by a factor of $k$. If we now let $k$ a function of $n$ (say $k=\sqrt{n}$) I think we can get amortised sub-linear times for all operations (in the case of using $\sqrt{n}$, that's also the complexity of the operations). – Raphael Feb 26 '13 at 07:46
  • 4
    This question seems to be related. – Raphael Feb 26 '13 at 10:40
  • 1
  • How does delete(x) affect the location of all objects after x? Do they decrease by 1? – Joe Feb 27 '13 at 18:07
  • @Joe, yes, that is correct. – Kaveh Feb 27 '13 at 18:16
  • @Raphael, the question looks like an exact duplicate to me – Joe Feb 28 '13 at 18:55
  • @Joe, it is relevant, but it is not exact duplicate. That question is about amortized analysis. – Kaveh Feb 28 '13 at 21:51
  • 1
    @kaveh but the answer is the same – Joe Feb 28 '13 at 23:05
  • I tend to agree with @Joe. Surely, any amortized worst-case lower bound is also a lower bound for the worst-case. Do you aim for the gap? If so, you should rephrase the question accordingly. – Raphael Mar 01 '13 at 01:24
  • @Joe, the answer doesn't need to be the same, so it is not an exact duplicate. It might be the case that for worst-case there are better lower-bounds. It is easy to come up with such ADTs to distinguish between worst-case and amortized. I already said in the first sentence that I care about worst-case. By the way, does Dietz's data-structure perform all of these in worst-case $\lg n /\lg \lg n$? That is not clear from Jeff's answer and neither the paper's abstract. If that is not the case, then it is also not clear if a stronger lower-bound doesn't holds in other models. – Kaveh Mar 01 '13 at 02:52
  • In fact Dietz's paper says "It would also be desirable to eliminate amortization.". It also assumes that the RAM words are of $\lg$ size. – Kaveh Mar 01 '13 at 02:59
  • The techniques used in exponential search trees might be of interest. http://user.it.uu.se/~arnea/ps/expTr.pdf – Joe Mar 01 '13 at 05:54

0 Answers0