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

This preview shows pages 1–8. Sign up to view the full content.

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.

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

View Full Document
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.
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.

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

View Full Document
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
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 .

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

View Full Document
Implementations Just like stacks, there are two families of implementations: Linked elements; Array-based.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern