0% found this document useful (0 votes)
30 views4 pages

P3a - Activities

The document discusses different types of queues including linear, circular, and priority queues. It provides examples of using queues in situations like a print server and hospital triage system. Tables are included showing the contents and changes to sample queues as items are added and removed.

Uploaded by

wilgaming420
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views4 pages

P3a - Activities

The document discusses different types of queues including linear, circular, and priority queues. It provides examples of using queues in situations like a print server and hospital triage system. Tables are included showing the contents and changes to sample queues as items are added and removed.

Uploaded by

wilgaming420
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

P3a – Queues A Level Computer Science (AQA 7517)

P3 – Data Structures Wakefield College

P3 | Data Structures

P3a | Queues
Objectives:

 Define the concept of an abstract data type


 Explain the concept and uses of a queue
 Describe the creation and maintenance of data within a queue (linear, circular, priority)
 Describe and apply the following to a linear, circular and priority queue
o add an item
o remove an item
o test for an empty queue
o test for a full queue

Activity 1
In a restaurant, the dessert chef must make the desserts in the order that they are requested
by the waiting staff.

Complete the table to show the missing items based on the information in each column.

Note:

 Array q starts at index 0


 front points to first item in the queue, initialised to 0
 rear points to last item in queue, initialised to -1
 Desserts = Yakgwa, Mochi, Trifle, Gelato, Sachertorte, Baklava

Request Operation Contents of array q size rear front Returns

is the queue
isEmpty() [‘ ‘,’ ‘,’ ‘,’ ‘,’ ‘] 0 -1 0
empty?
enQueue(Y),
add Y, add M [Y,M,’ ‘,’ ‘,’ ‘] 2 1 0 Nothing
enQueue(M)

Add T

remove one item

is the queue full?

add G, add S
how many
elements in the
queue?
remove 1
P3a – Queues A Level Computer Science (AQA 7517)
P3 – Data Structures Wakefield College

Is the queue full?

Question Answer
How do you tell if the queue is
full?
Are there any problems with this
implementation of the queue
ADT as a static array?
P3a – Queues A Level Computer Science (AQA 7517)
P3 – Data Structures Wakefield College
Activity 2
A print server keeps all submitted jobs in a circular queue.

Complete the table for a server to show the missing print jobs based on the information in
the first column.

Note:

 The array is indexed from 0..4


 Front points to the next item to remove from the queue, initialised to 0
 Rear points to last item in queue, initialised to -1
 Print job ID = J<number>; for example J38, J21

Queue

front rear size [0] [1] [2] [3] [4]

Initialise 0 -1 0

Add J45 0 0 1 J45

Add J38

Add J92

Remove 1

Remove 1

Add J44

Add J55

Add J66

Add J77

Remove 1

Add J04

Remove 1

Remove 1

Question Answer
How many are there in the
queue at the end?
Where is the front of the queue
at the end?
P3a – Queues A Level Computer Science (AQA 7517)
P3 – Data Structures Wakefield College
Activity 3
An accident and emergency room triage system rates each new patient according to a 3
point system. One is the highest priority and 3 is the lowest priority. A priority queue is
maintained of patients in the order that they are to be seen. (You can assume that the queue
will always be long enough to accommodate all patients, and that the first to be seen will
always be at q[0].)

Complete the table for an accident and emergency department to show the missing items
based on the information in the first column.

Note:

 Queue implemented as dynamic data structure, starting at q[0]


 Pointers to front and rear of queue are not needed
 Same priority items are added at the end of all equivalents
 Patient ID = <priority><last initial><first initial>; for example 3DA, 2HG, 1NB

Queue q

[0] [1] [2] [3] [4]

Add 2HG

Add 3DA

Add 1NB

Add 2NF

Remove 1

Remove 1

Add 3FC

Add 2AB

Add 1WT

Remove 1

Add 2CS

Remove 1

Add 3DS

You might also like