Reputation: 63
I've heard that this way of implementation is cost-effective since Qing and deQing has amortized constant time complexity. Isn't that queueing with 2 pointers (head and tail) has also almost constant time complexity?
Upvotes: 1
Views: 156
Reputation: 65458
Stacks have a trivial purely functional implementation; queues don't. This property and related ones (e.g., decorating the stacks to support a Minimum() operation so that the queue supports the same) cover all of the non-curiosity uses of which I'm aware.
Upvotes: 2