A Level Computer Science OCR Practice Exam 2025 – Complete Study Resource

Question: 1 / 400

In what structure are elements accessed in last-in first-out (LIFO) order?

Array

Queue

Stack

Elements are accessed in last-in first-out (LIFO) order in a stack. This data structure allows for the most recently added element to be the first one to be removed. Stacks operate on the principle that the last element added to the collection is the first one to be removed, which is akin to a stack of plates where you can only take the top plate off.

In practical terms, when using a stack, operations such as push (to add an element) and pop (to remove the element) are performed at the top of the stack. This behavior is very useful in scenarios such as function call management in programming, where the last function called must finish its execution before the previous function can continue.

The other structures mentioned do not operate on LIFO principles. Arrays allow for random access based on their index, queues operate in a first-in first-out (FIFO) manner, and lists may have various access patterns but typically do not adhere to LIFO without being explicitly defined as a stack. Thus, the stack uniquely fits the definition of accessing elements in LIFO order.

Get further explanation with Examzify DeepDiveBeta

List

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy