Anda di halaman 1dari 2

Example Queue and Stack Questions

Printer Queues

The following queue is a printer queue. Output waiting to be printed in a networked


computer room is stored in a queue on disk. The output is printed on a FIFO basis
with each job processed in turn.

The queue looks like this:

Job 1 Job 2 Job 3 Job 4 Job 5

Front Rear

Pointers mark the front and rear of the queue.

What will the queue look like when 4 jobs have been printed and 2 new jobs, Job 6
and Job 7, have joined the queue? Remember to mark in the pointers Front and
Rear.

Stacks of People!

A stack of employee names stored on disk currently looks like this:

7
6
5
4
3
Top of stack pointer  2 KATE
1 SAM

Show the state of the stack and the stack pointer after each of operations on the
following page.

Anda mungkin juga menyukai