DEV Community

Discussion on: Stacks vs. Queues In JavaScript

Collapse
 
felipernb profile image
Felipe Ribeiro

Nice article!

The only issue with implementing stacks and queues on top of dynamically sized arrays is that you don't have a guarantee on the complexity of the insertion or removal of elements, as the array might need to do some copying and resizing underneath. It might still be an amortized constant time, while a linked list would actually always give you O(1).

But maybe linked lists could be the next topic on the Data Structures With JavaScript series? :)