Name most efficient way to implement Stack and Queue together?

Technology CommunityCategory: QueuesName most efficient way to implement Stack and Queue together?
VietMX Staff asked 3 years ago
  • A doubly linked list, has all the computational complexity attributes, but poor cache locality.
  • ring buffer (array) that allows for appending and removing at head and tail has the same complexity characteristics. It uses a dynamic array and requires reallocation, once the number of elements grows beyond it’s capacity.
  • Similar to an array list/vector generally being faster in practice for sequential access versus a linked list. In most cases it will be faster and more memory efficient than using a doubly linked list implementation.