Prepare for the A Level Computer Science OCR Exam with engaging quizzes, detailed explanations, and effective study tips. Maximize your readiness and boost your confidence for exam day!

Practice this question and more.


What operation does a stack support?

  1. Only push operations

  2. Push and pop operations

  3. Only pop operations

  4. Both enqueue and dequeue operations

The correct answer is: Push and pop operations

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. The primary operations that a stack supports are push and pop. The push operation allows an element to be added to the top of the stack, while the pop operation removes the top element from the stack. This pair of operations enables stacks to maintain their structured order, making them suitable for various applications such as function call management, expression evaluation, and backtracking algorithms. In summary, stacks facilitate the addition and removal of elements in a specific order through push and pop operations, which are vital for their functionality and usability in computing tasks.