Reputation: 1382
According to
Columbia Notes, page 4 and 5
We can implement a queue with an array or a linked list.
...
We can implement a stack with an array or a linked list.
Is it a sinlge linked list or a double linked list?
Also, when is an array used and when is the linked structure used?
Upvotes: 2
Views: 198
Reputation: 533472
Stacks are typically implemented using an arrays. This is because items are always added/removed from the same end. The other end never moves.
Queues are typically implemented as singly linked lists as this is the simplest implementation. It can be implemented as an array, but this is harder and was only added in Java in version 6.
Upvotes: 4