A stack is a data structure that follows the Last In, First Out (LIFO) principle, meaning that the last element added to the stack is the first one to be removed. This is like a stack of plates, where the last plate added is the first one to be taken off. A queue, on the other hand, follows the First In, First Out (FIFO) principle, meaning that the first element added to the queue is the first one to be removed. This is like a line at a grocery store, where the first person in line is the first one to be served. In summary, a stack is a LIFO data structure and a queue is a FIFO data structure.
First read the answer fully, then try to explain it in your own words. After that, open a few related questions and compare the concepts. This method helps you remember the topic for a longer time and improves exam preparation.