Skip to content

Queue

storing

Level 1 of 3

Also called First in, first out.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from queue's own run on the numbers shown.

choose one

question 1

An empty queue is given 14, 97, -, 20, 30, -. Each number joins, and each dash lets the front one leave. What does the line hold then, front first?

the answer, and why

the answer is D

14 leaves first, the oldest. Then 20 and 30 join behind 97, and the last dash lets 97 leave.

if you chose another

  • That is a stack's answer, where each dash takes the newest. A leave always takes the front.
  • That misses the last leave, which lets 97 go.
  • That reads the line from the back. Front first, 20 leads.

new numbersthe test page's numbers

question 2

How many numbers leave an empty queue given -, 73, 33, -, -, -, 15, -?

the answer, and why

the answer is D

The first dash finds the line empty. 73 and 33 join and leave in turn. The next dash finds it empty again, then 15 joins and leaves.

if you chose another

  • That counts every dash, but the first and the fourth find the line empty.
  • That counts one of the two dashes that find the line empty.
  • That counts every operation, the joins too.

new numbersthe test page's numbers