Siemens interview question

Explain the difference between a stack and a queue.

Interview Answer

Anonymous

5 Aug 2024

A stack is a data structure that follows the Last In, First Out (LIFO) principle, meaning that the last element added is the first one to be removed. Operations on a stack include push (adding an element), pop (removing the top element), and peek (viewing the top element without removing it).