Domanda di colloquio di Vayu

Explain the difference between a stack and a queue.

Risposta di colloquio

Anonimo

27 lug 2024

Answer: A stack is a linear data structure that follows the Last In First Out (LIFO) principle, where the last element added is the first to be removed. Common operations are push, pop, and peek. A queue, on the other hand, follows the First In First Out (FIFO) principle, where the first element added is the first to be removed. Common operations are enqueue (adding an element), dequeue (removing an element), and peek.