You are on page 1of 8

POLYTECHNIC SULTAN MIZAN ZAINAL ABIDIN

DEPARTMENT OF INFORMATION AND COMMUNICATION TECHNOLOGY

DFC30233

DATA

STRUCTURE
TOPIC CHAPTER 1 2 3 4

ASSESMENT EXERCISE 4

NAME Muhammad Aiman bin Mahadi


REG NO 13DDT21F1029

PROGRAMME DDTS5

INSTRUCTIONS :
1.Answer ALL the questions

2.Submit on ………………….

MARKING SCHEME

CLO2PPLO3

TOTAL /

THE ENTIRE QUESTION IS BASED ON JTMK’S QUESTION BANK APPROVED BY

PROGRAMME LEADER. SIGNATURE IS NOT REQUIRED.


EXERCISE 4: QUEUE

Activity 4A
Activity Outcome: Define queue and the implementation of queue in real life

1.What is Queue?
Abstract data in database is a collection of items in which only the earliest added item may be
accessed
2.Give TWO example of queue in real life

Cashier line
bank

Activity 4B
Activity Outcome: Differentiate between linear implementation and circular array

1. What the differences of queue in linear and queue in circular array?

Queue in linear Queue in circular array


Arranges the data in a linear pattern Arranges the data in a circular order
linear queue requires more memory space It requires less memory space

Activity 4C
Activity Outcome: Explain the FIFO operation in queue

1. Explain FIFO operation in queue.


 -The first element added to the queue will be the first one to be removed.
Activity 4D
Activity Outcome: Use array and linked list to representing queue

a) Given below is the content of a array implementation of a queue:

queue 0 1 2 3 4 5
70
80 90

front rear

Show the contents of the queue and the locations of front and rear after doing the
following instruction:

i. queue.dequeue( );
ii. queue.dequeue( );
iii. queue.enqueue(7);
iv. queue.enqueue(8); v.
queue.enqueue(9);
vi. queue.enqueue(10);

b)

NULL

Show the new diagrams after this operation:

i. Enqueue ( 70, &S) ii.


Enqueue ( 80, &S)
iii.Enqueue ( 90, &S)
iv.Dequeue (&S)
v.Dequeue ( &S)

Activity 4E
Activity Outcome: Apply queue in problem solving
1) Draw suitable Circular Queue diagram for each statement below. Show front,rear and count
according to related diagram.
a)Create CircularQueue(Q); Size = 3
b)enqueue(3,Q);
c)enqueue(7,Q);
d)dequeue(Q);
e)enqueue(9,Q);
f)IsEmpty(Q);

2) Draw suitable Circular Queue diagram for each statement below. Show front,rear and count
according to related diagram.
a)Create CircularQueue(T); Size = 5
b)enqueue(E,T);
c)enqueue(S,T);
d)enqueue(W,T);
e)dequeue(T);
f)enqueue(R,T);
g)enqueue(Z,T);
h)IsFull(T);

You might also like