Explain the terms "stack" and "queue.
Explain the terms "stack" and "queue.
A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. This means the last element added to the stack will be the first one to be removed. Think of a stack like a stack of plates: you add and remove plates from the top of the stack.
A queue is a linear data structure that follows the First In, First Out (FIFO) principle. This means the first element added to the queue will be the first one to be removed. Think of a queue like a line at a ticket counter: the first person in line is the first one served.