A queue is a linear, homogeneous, container that stores and dispenses its content in a FIFO manner. FIFO - First In First Out The first (most distant)

Slides:



Advertisements
Similar presentations
STACKS & QUEUES. Stacks Abstract data types An abstract data type (ADT) is an abstraction of a data structure An ADT specifies : –Data stored –Operations.
Advertisements

1 Array-based Implementation An array Q of maximum size N Need to keep track the front and rear of the queue: f: index of the front object r: index immediately.
Ceng-112 Data Structures I Chapter 5 Queues.
Queues1 Part-B2 Queues. Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions follow the first-in first-out scheme.
COSC 1P03 Data Structures and Abstraction 9.1 The Queue Whenever you are asked if you can do a job, tell 'em, "Certainly, I can!" Then get busy and find.
Stacks, Queues, and Deques. 2 A stack is a last in, first out (LIFO) data structure Items are removed from a stack in the reverse order from the way they.
Topic 9 The Queue ADT.
CHAPTER 7 Queues.
1 Queues (5.2) CSE 2011 Winter May Announcements York Programming Contest Link also available from.
CHAPTER 4 Queues. Queue  The queue, like the stack, is a widely used data structure  A queue differs from a stack in one important way  A stack is.
Chapter 5 Queues Modified. Chapter Scope Queue processing Comparing queue implementations 5 - 2Java Software Structures, 4th Edition, Lewis/Chase.
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.
Queues. What is a queue? First-in first-out data structure (FIFO) New objects are placed at rear Removal restricted to front Examples?
Queues. What is a queue? First-in first-out data structure (FIFO) New objects are placed at rear Removal restricted to front Examples?
Unit 11 1 Unit 11: Data Structures H We explore some simple techniques for organizing and managing information H This unit focuses on: Abstract Data Types.
Queues.
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.
Queues What is a queue? Queue Implementations: –As Array –As Circular Array –As Linked List Applications of Queues. Priority queues.
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.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Odds and Ends Strings (from Chapter 9) StringTokenizer.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 13: Queues and Vectors.
CS 106 Introduction to Computer Science I 12 / 13 / 2006 Instructor: Michael Eckmann.
© 2004 Goodrich, Tamassia Queues1. © 2004 Goodrich, Tamassia Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions.
Queues What is a Queue? Queue Implementations: Queue As Array
CSE 373 Data Structures and Algorithms Lecture 2: Queues.
CHAPTER 05 Compiled by: Dr. Mohammad Omar Alhawarat Stacks & Queues.
Software reuse means to “borrow” existing code. How can you reuse an existing class to make a new one? Such reuse is really an adaptation -- using the.
Cosc237/data structures1 Data Types Every data type has two characteristics: 1.Domain - set of all possible values 2.set of allowable operations Built-in.
1 Stacks and Queues Starring: IndexOutOfBOundsException Co-Starring: NoSuchElementException.
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.
Queues Chapter 6. Chapter 6: Queues Chapter Objectives To learn how to represent a waiting line (queue) and how to use the five methods in the Queue interface:
1 Chapter 20 Lists, Stacks, Queues Lecture 7 Dr. Musab Zghoul برمجة هيكلية.
A queue is a linear, homogeneous, container that stores and dispenses its content in a FIFO manner. FIFO - Fast In First Out The first (most distant) item.
Lecture7: Queue Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Chapter Objectives  Learn how to represent a waiting line (queue)  Become proficient using the methods in the Queue  Understand how to implement the.
Stacks and Queues. 2 3 Runtime Efficiency efficiency: measure of computing resources used by code. can be relative to speed (time), memory (space), etc.
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.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
CSE 373: Data Structures and Algorithms Lecture 2: Queues.
M180: Data Structures & Algorithms in Java Queues Arab Open University 1.
A stack is a linear, homogeneous, container that stores and dispenses its content in a LIFO manner. LIFO - Last In First Out The last (most recent) item.
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.
1 Queues (Continued) Queue ADT Linked queue implementation Array queue implementation Circular array queue implementation Deque Reading L&C , 9.3.
Queues By Jimmy M. Lu. Overview Definition Standard Java Queue Operations Implementation Queue at Work References.
Stacks and Queues. 2 Abstract Data Types (ADTs) abstract data type (ADT): A specification of a collection of data and the operations that can be performed.
Queues.
Stack A stack is a linear, homogeneous, container that stores and dispenses its content in a LIFO manner. LIFO - The last (most recent) item inserted,
Stack A stack is a linear, homogeneous, container that stores and dispenses its content in a LIFO manner. LIFO - The last (most recent) item inserted,
Stack A stack is a linear, homogeneous, container that stores and dispenses its content in a LIFO manner. LIFO - The last (most recent) item inserted,
CSE 373: Data Structures and Algorithms
Stacks and Queues.
Queues What is a queue? Queue Implementations: As Array
Topic 16 Queues Adapted from Mike Scott’s materials.
Queues 11/9/2018 6:28 PM Queues 11/9/2018 6:28 PM Queues.
Queues 11/16/2018 4:19 AM Queues 11/16/2018 4:19 AM Queues.
Queues.
Stacks and Queues.
Queues 11/22/2018 6:47 AM 5.2 Queues Queues Dr Zeinab Eid.
CSC 143 Queues [Chapter 7].
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 12/30/2018 9:24 PM Queues 12/30/2018 9:24 PM Queues.
Stacks and Queues CLRS, Section 10.1.
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
Queues What is a Queue? Queue Implementations: As Array
Queues Jyh-Shing Roger Jang (張智星)
QUEUE Visit for more Learning Resources Free Powerpoint Templates.
Stacks and Queues.
Queues What is a queue? Queue Implementations: As Array
Presentation transcript:

A queue is a linear, homogeneous, container that stores and dispenses its content in a FIFO manner. FIFO - First In First Out The first (most distant) item inserted, and not yet removed, will be the first (next) item dispensed. Real World Examples The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

enqueue insert a new item into the queue dequeue remove one item from the container front inspect one item from the container, but don’t remove it An Abstract Picture The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

Class Specification The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub. Domain sequence of ItemType Constructor public Queue() post: this == sequence{} Query methods public boolean isEmpty() post: result == ( this-> size() == 0) public ItemType front() pre: ! isEmpty() post: result == this-> first() Update methods public void enqueue(ItemType z) post: this == -> append( z ) public void dequeue() pre: ! isEmpty() (throws java.util.NoSuchElementException) post: this == -> subSequence( 2, -> size() ) Queue

Example The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub. Queue + Queue() + boolean isEmpty() + void enqueue(ItemType z) + void dequeue() + ItemType front() Queue q1, q2; String str; q1 = new Queue (); q1.enqueue( “droopy” ); q1.enqueue( “rupie” ); q1.enqueue( “snoopy” ); q1.dequeue(); q1.enqueue( “soupy” ); str = q1.front(); q1.enqueue( “loopy” ); q1.enqueue( “goopy” ); q1.dequeue(); q1.enqueue( q1.front() ); q2 = new Queue(); while ( !q1.isEmpty() ) { q2.enqueue( q1.front() ); q1.dequeue(); }

In the computing environment...  is queued.  Graphical User Interfaces (GUIs) depend upon ______________.  Documents sent to the printer are ___________ (queued).  Data transferred to a stream are ____________ (queued).  Machine instructions are executed using a sophisticated queue, known as a ____________. The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

Suppose you inherit LinkedList. Which end of the list is the front of the queue? How does the code for enqueue differ from dequeue? How many iterators? Double or single linking? Suppose you use an array to store the queue content. What happens when the number of enqueues exceeds the array length? The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

Bounded List Representation This is best accomplished by treating an array like it is a circular structure, also called a ring buffer. [0] [1] [2] [3] [size] 1 3 newest oldest oldest is the index of the queue’s front newest is the index of the queue’s rear Note: This representation requires n+1 cells for a queue of length n. The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.