Pregunta de entrevista de Cognizant

Explain the difference between stack and queue data structures.

Respuesta de la entrevista

Anónimo

5 sept 2024

Stack: A stack follows the Last In, First Out (LIFO) principle, meaning the last element added is the first to be removed. Operations are typically performed at one end, called the "top" of the stack.Queue: A queue follows the First In, First Out (FIFO) principle, meaning the first element added is the first to be removed. Operations are performed at both ends: elements are added at the "rear" and removed from the "front."