Lect11_linkedQueue

Lect11_linkedQueue - ITI 1121. Introduction to Computing II...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
ITI 1121. Introduction to Computing II * Marcel Turcotte School of Information Technology and Engineering Version of March 1, 2010 Abstract Queues LinkedQueue * These lecture notes are meant to be looked at on a computer screen. Do not print them unless it is necessary.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Definitions A queue is a linear abstract data type such that insertions are made at one end, called the rear , and removals are made at the other end, called the front . Queues are sometimes called FIFOs: first-in first-out . enqueue() Queue dequeue() The two basic operations are: enqueue: adds an element to the rear of the queue; dequeue: removes and returns the element at the front of the queue. Software queues are similar to physical ones: queuing at the supermarket, at the bank, at cinemas, etc.
Background image of page 2
Applications Shared resources management (system programming): Access to the processor; Access to the peripherals such as disks and printers. Application programs: Simulations; Generating sequences of increasing length over a finite size alphabet; Navigating through a maze.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example public class Test { public static void main( String[] args ) { Queue<Integer> queue = new QueueImplementation<Integer>(); for ( int i=0; i<10; i++ ) queue.enqueue( new Integer( i ) ); while ( ! queue.isEmpty() ) System.out.println( queue.dequeue() ); } } What does it print? 0, 1, 2, 3, 4, 5, 6, 7, 9
Background image of page 4
q = new Q(); q.enqueue( a ); q.enqueue( b ); q.enqueue( c ); q.dequeue( ); -> a q.dequeue( ); -> b q.enqueue( d ); q.dequeue( ); -> c q.dequeue( ); -> d Elements of a queue are processed in the same order as the they are inserted into the queue, here “a” was the first element to join the queue and it was the first to leave the queue: first-come first-serve .
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Implementations Just like stacks, there are two families of implementations: Linked elements; Array-based.
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/06/2011 for the course ITI 1121 taught by Professor Samaan during the Spring '10 term at University of Ottawa.

Page1 / 50

Lect11_linkedQueue - ITI 1121. Introduction to Computing II...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online