At a hill station, the parking lot is one long driveway snaking up a hillside.…

2009

At a hill station, the parking lot is one long driveway snaking up a hillside. Cars drive in and park right behind the car in front of them, one behind another. A car cannot leave until all the cars in front of it have left. The parking lot is more like:

  1. A.

    An array

  2. B.

    A stack

  3. C.

    A queue

  4. D.

    A linked list

Show answer & explanation

Correct answer: C

Concept

  • A queue is First-In-First-Out (FIFO): the item that entered earliest is always the first one that becomes free to leave.

  • A stack is Last-In-First-Out (LIFO): the item that entered most recently is always the first one that becomes free to leave.

  • An array is direct, index-addressed storage, and a linked list is a pointer-chained sequence of nodes — neither imposes any arrival-order rule on removal by itself.

Application

  1. Each car parks immediately behind the car that parked just before it, so the parking order fixes one strict single-file line — the setup itself calls the earlier-parked car "the car in front" of the one that follows it.

  2. The departure rule says a car cannot leave until every car "in front of it" has left — that is, until every car that parked earlier than it has already left.

  3. So the earliest-parked car is free to leave first (no earlier car to wait on), the next-earliest can leave only once the first one has gone, and so on: cars leave in exactly the order they arrived.

Cross-check

  • This is the opposite of stack (LIFO) behaviour, which would require the most recently parked car to leave first; here the departure rule ties directly to arrival order, not its reverse.

  • Array and linked list describe storage/traversal mechanics, not an enforced entry-order-equals-exit-order rule, so neither models the constraint in the stem.

  • Enter-order-equals-exit-order is exactly First-In-First-Out, which is the defining behaviour of a queue.

Explore the full course: Coding For Placement

Loading lesson…