OA. free
Free
Accenture Core Computer Science Core Computer Science Medium

Mr.

Accenture technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Mr. Aoki is planning to visit the shrine for New Years. However, the parking lot at the shrine is very small. Once you park your car, you cannot leave until all of the cars that came after you leave. Choose the data structure that best represents the situation in this parking lot.

Choose one option.
Show answer & explanation
Answer: A. stack

This parking lot operates on a Last-In-First-Out (LIFO) principle: the last car to arrive must leave first before earlier cars can exit. This is the defining characteristic of a stack. A queue would allow the first car in to leave first, which contradicts the problem. A heap and linked list are not designed to enforce this specific ordering constraint.

Step-by-step Derivation:
Analyze the parking lot constraint: 'Once you park your car, you cannot leave until all of the cars that came after you leave.' This means if cars arrive in order A → B → C, then C must leave first, then B, then A. This is Last-In-First-Out (LIFO), which is exactly how a stack operates. A stack uses push (add to top) and pop (remove from top) operations. In contrast, a queue uses FIFO (First-In-First-Out), where the first car to arrive would leave first—the opposite of this scenario.