Difference between using LinkedList and ArrayDeque to implement Queue

http://stackoverflow.com/questions/6163166/why-is-arraydeque-better-than-linkedlist

Accessing an element in ArrayDeque is always faster compared to LinkedList with O(1) for accessing elements. In Linked list, it will take O(N) to find last element.

ArrayDeque is memory efficient since you don't have to keep track of next node unlike in Linked List.

Even as per java documentation, it has been quoted that

ArrayDeque is Resizable-array implementation of the Deque interface. Array deques have no capacity restrictions; they grow as necessary to support usage. They are not thread-safe; in the absence of external synchronization, they do not support concurrent access by multiple threads. Null elements are prohibited. This class is likely to be faster than Stack when used as a stack, and faster than LinkedList when used as a queue.

results matching ""

    No results matching ""