Topic 16 Queues Adapted from Mike Scott’s materials.

Slides:



Advertisements
Similar presentations
Queues and Linked Lists
Advertisements

Queues 4/14/2017 5:24 PM 5.2 Queues Queues Dr Zeinab Eid.
CSC 212 – Data Structures. Using Stack Stack Limitations  Great for Pez dispensers, JVMs,& methods  All of these use most recent item added only 
CS 206 Introduction to Computer Science II 10 / 22 / 2008 Instructor: Michael Eckmann.
Queues Chapter 6. Chapter Objectives  To learn how to represent a waiting line (queue) and how to use the methods in the Queue interface for insertion.
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
Queues What are queues? Queue Implementation Using Linked Lists. Applications of Queues.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
Queues Chapter 6. Chapter 6: Queues2 Chapter Objectives To learn how to represent a waiting line (queue) and how to use the methods in the Queue interface.
Fall 2007CS 2251 Queues Chapter 6. Fall 2007CS 2252 Chapter Objectives To learn how to represent a waiting line (queue) and how to use the methods in.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 13: Queues and Vectors.
Implementing and Using Stacks
Chapter 6.6, (event-driven simulation) Queues 1CSCI 3333 Data Structures.
CSE 373 Data Structures and Algorithms Lecture 2: Queues.
Data Structures - Queues
COMP 121 Week 14: Queues. Objectives Learn how to represent a queue Learn how to use the methods in the Queue interface Understand how to implement the.
Data Structures (part 2). Stacks An Everyday Example Your boss keeps bringing you important items to deal with and keeps saying: “Put that last ‘rush’
© A+ Computer Science - A queue is a group of same-type values. Values are added to the back of a queue and removed from the front.
Cousin of the Stack.  An abstract data type (container class) in which items are entered at one end and removed from the other end  First In First.
UNIT II Queue. Syllabus Contents Concept of queue as ADT Implementation using linked and sequential organization. – linear – circular queue Concept –
CSE 373: Data Structures and Algorithms Lecture 2: Queues.
Topic 16 Queues "FISH queue: n. [acronym, by analogy with FIFO (First In, First Out)] ‘First In, Still Here’. A joking way of pointing out that processing.
Give Eg:? Queues. Introduction DEFINITION: A Queue is an ordered collection of element in which insertions are made at one end and deletions are made.
Queues 1. Queue  a queue represents a sequence of elements where elements can be added at the back of the sequence and removed from the front of the.
1 Lecture 15: Big O Notation (Wednesday) Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science Test See Web for Details Don’t be deleted!
1 Lecture 9: Stack and Queue. What is a Stack Stack of Books 2.
Unit 2 - Stack and Queue Slides 18 to end. Queue CMPT Anne Lavergne18.
© 2004 Goodrich, Tamassia Queues. © 2004 Goodrich, Tamassia Stacks2 The Queue ADT The Queue ADT stores arbitrary objects Insertions and deletions follow.
Queues1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich,
Linked Data Structures
Queues Chapter 8 (continued)
Week 4 - Monday CS221.
Queues 5/11/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H.
G64ADS Advanced Data Structures
QueueStack CS1020.
Linked List Stacks, Linked List Queues, Dequeues
Heaps And Priority Queues
CSE 116/504 – Intro. To Computer Science for Majors II
CSE 373: Data Structures and Algorithms
Lectures Queues Chapter 8 of textbook 1. Concepts of queue
Stacks and Queues.
Queues Queues Queues.
Topic 16 Queues "FISH queue: n.
Basic Data Types Queues
CMSC 341 Lecture 5 Stacks, Queues
structures and their relationships." - Linus Torvalds
Queues.
Queue, Deque, and Priority Queue Implementations
Queue, Deque, and Priority Queue Implementations
Queues.
Topic 16 Queues "FISH queue: n.
Queues 11/22/2018 6:47 AM 5.2 Queues Queues Dr Zeinab Eid.
Queues: Implemented using Arrays
Queues 3/9/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
Queues A first-in, first-out or FIFO data structure.
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
Stack A data structure in which elements are inserted and removed only at one end (called the top). Enforces Last-In-First-Out (LIFO) Uses of Stacks Evaluating.
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
Priority Queues & Heaps
More Data Structures (Part 1)
CSC 248 – fundamentals of Data structure
Queues cont. Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
Queues: Implemented using Linked Lists
Stacks, Queues, and Deques
Revised based on textbook author’s notes.
structures and their relationships." - Linus Torvalds
Lecture 9: Stack and Queue
CMPT 225 Lecture 8 – Queue.
Data Structures & Programming
Presentation transcript:

Topic 16 Queues Adapted from Mike Scott’s materials

Queues In England people don’t “get in line” they “queue up”. Like a line In England people don’t “get in line” they “queue up”. CS314 Queues

Queue Properties Queues are a first in first out data structure FIFO (or LILO, but that sounds a bit silly) Add items to the end of the queue Access and remove from the front Access to the element that has been in the structure the longest amount of time Used extensively in operating systems Queues of processes, I/O requests, and much more CS314 Queues

Queues in Operating Systems On a computer with N cores on the CPU, but more than N processes, how many processes can actually be executing at one time? One job of OS, schedule the processes for the CPU CS314 Queues

Queue operations enqueue(E item) E front() E dequeue() a.k.a. add(E item) E front() a.k.a. E peek() E dequeue() a.k.a. E remove() boolean isEmpty() Specify methods in an interface, allow multiple implementations. CS314 Queues

Queue interface, version 1 public interface Queue<E> { //place item at back of this Queue enqueue(E item); //access item at front of this Queue //pre: !isEmpty() E front(); //remove item at front of this Queue //pre: !isEmpty() E dequeue(); boolean isEmpty(); } CS314 Queues

Implementing a Queue Given the internal storage container and choice for front and back of queue what are the Big O of the queue operations? Array LinkedList (Singly Linked) enqueue front dequeue isEmpty CS314 Queues

Question If implementing a queue with a singly linked list with references to the first and last nodes (head and tail) which end of the list should be the front of the queue in order to have all queue operations O(1)? The front of the list should be the front of the queue The back of the list should be the front of the queue. Either end will work to make all ops O(1) Neither end will allow all ops to be O(1) CS314 Queues