ArrayDeque<> vs LinkedList<>

#1

In EPI it says that the preferred implementation of the Deque interface is the ArrayDeque class. And for most of the stack problems in EPI ArrayDeque is used. However for the initial implementation of the max API (problem 8.1 EPI java) Inside of the stack class we have: “private Deque elementWithCachedMax = new LinkedList<>().” Is the LinkedList class used here simply to show that we can also use a LinkedList class to implement the Deque interface, or is there a performance advantage to using LinkedList<> for this particular problem? When implementing Deque when should we use LinkedList and when should we use ArrayDeque?

0 Likes

#2

Hi @programmer99,

Thanks for your question, and I think it is just missing of migrations of LinkedList to ArrayDeque. I have looked at our repository, and making sure those are migrated now. Feel free to let us know if you have any question.

1 Like