What is the runtime of the DualArrayDeque get(i) operation?
O(1)
What is the runtime of the DualArrayDeque set(i,x) operation?
O(1)
What is the runtime of the DualArrayDeque add(i,x) operation?
O(min{i, n-i}), amortized
What is the runtime of the DualArrayDeque remove(i) operation?
O(min{i, n-i}), amortized.
How much extra space does a DualArrayDeque use to store n elements?
O(n)
What is the backing storage of a DualArrayDeque?
2 ArrayStacks.
What index i yields the worst-case runtime for the DualArrayDeque add(i,x) operation?
i=n/2
In this case, the runtime is O(n), since min{i, n-i}=n/2 when i=n/2.
What index i yields the best-case runtime for the DualArrayDeque add(i,x) operation?
Both i=0 and i=n-1.
These have O(1) runtime.
Pros of DualArrayDeque
Good (O(1) amortized) runtime to add and remove from both ends (so, a good implementation of the Deque interface)
Good (O(1)) random access.
Cons of DualArrayDeque
Not good to add/remove from the middle.
O(n) extra space required.
More complex than ArrayDeque, yet doesn’t give an improvement to runtime.