[go: up one dir, main page]

0% found this document useful (0 votes)
254 views2 pages

Computer Science Students' Guide

The document discusses queues and keyboard buffers implemented as circular queues. It provides examples of initializing and performing operations on a circular queue representing a keyboard buffer. It asks to write pseudocode for queue operations like isFull and deQueue. It also discusses priority queues from a user perspective and how abstraction hides implementation details.

Uploaded by

youxufmoghal
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)
254 views2 pages

Computer Science Students' Guide

The document discusses queues and keyboard buffers implemented as circular queues. It provides examples of initializing and performing operations on a circular queue representing a keyboard buffer. It asks to write pseudocode for queue operations like isFull and deQueue. It also discusses priority queues from a user perspective and how abstraction hides implementation details.

Uploaded by

youxufmoghal
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/ 2

Homework 2 Queues

Unit 7 Data structures

Homework 2: Queues
1. A keyboard buffer on a computer’s operating system is implemented as a circular queue.

(a) Explain why a circular queue is an appropriate data structure choice. [2]

(b) A particular keyboard buffer consists of five cells in a circular queue. The queue
kBuffer is initialised by setting a variable size (containing the number of items in the
array) to 0, pointers front to 0 and rear to -1. A variable maxSize holds the maximum
size of the queue.

(i) Complete the table to show the results after the following operations. [4]
kBuffer
[0] [1] [2] [3] [4] size front rear
Initial state 0 0 -1
Enqueue S
Enqueue W
Dequeue
Enqueue E

(ii) Complete the table to show the results after the following operations. [3]
kBuffer
[0] [1] [2] [3] [4] size front rear
Current state J U X L M 3 1 3
Enqueue T
Enqueue R
Dequeue

(c) Code for the keyboard buffer operations needs to be written.


Use the variables defined in part (b): kBuffer, maxSize, size, front, and rear.
(i) Write the pseudocode for the isFull() operation, including function header. [2]

1
Homework 2 Queues
Unit 7 Data structures

(ii) Write the pseudocode for the deQueue operation. [4]

(d) (i) Describe, with the aid of an example, the operation of a priority queue from the
user’s point of view. [2]

(ii) Explain how the principles of data abstraction and encapsulation can be used to
hide the details of implementation of a priority queue. [3]

Total 20 marks

You might also like