Frage im Vorstellungsgespräch bei Introspect Technology

What is the difference between a stack and a queue?

Antwort im Vorstellungsgespräch

Anonym

28. Juni 2021

A stack is an ordered list of elements where items enter and exit from the same side (i.e., items can be popped off of or pushed on the stack, and the first element to be put on is the last one to be taken off). A queue on the other hand allows elements to be added from one side and removed on the other side. This allows for the first-in-first-out structure, and may be modeled by a linked-list.