logo

AQA A-Level Computer Science practice

A priority queue contains three jobs: Job A with priority 2, Job B with priority 5, and Job C with priority 1. The system removes one job and then adds Job D with priority 4. State the order in which the next three removals should occur, assuming a larger number means a higher priority. Explain your answer and include the relevant queue operations.

Try the question first, then check the answer and practise the same topic again.

At a glance

Question

Type

practice

Style

Topic

Queues

Exam-style question

Try this first

A priority queue contains three jobs: Job A with priority 2, Job B with priority 5, and Job C with priority 1. The system removes one job and then adds Job D with priority 4. State the order in which the next three removals should occur, assuming a larger number means a higher priority. Explain your answer and include the relevant queue operations.

Answer and explanation

Concise answer

The first remove operation removes Job B because it has the highest priority, 5.

Why this is correct

A priority queue orders removal by priority rather than by the order in which items were added. The empty and full tests are still required to make removal and addition safe.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions