Pergunta de entrevista da empresa Vayu

Explain the difference between a stack and a queue.

Resposta da entrevista

Sigiloso

27 de jul. de 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.