1 Lecture 14: Queues Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science.

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

Stacks, Queues, and Linked Lists
Data Structure HKOI training /4/2010 So Pak Yeung.
1 CompSci 105 SS 2005 Principles of Computer Science Lecture 11: Linked Lists Lecturer: Santokh Singh Assignment 2 due tomorrow, i.e. Friday 21 Jan 2005.
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.
§3 The Stack ADT 1. ADT A stack is a Last-In-First-Out (LIFO) list, that is, an ordered list in which insertions and deletions are.
Queues.
Review of Stacks and Queues Dr. Yingwu Zhu. Our Focus Only link-list based implementation of Stack class Won’t talk about different implementations of.
0 of 37 Stacks and Queues Lecture of 37 Abstract Data Types To use a method, need to know its essentials: signature and return type o additionally,
Queue RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
CS Data Structures II Review COSC 2006 April 14, 2017
© 2006 Pearson Addison-Wesley. All rights reserved8-1 Chapter 8 Queues CS102 Sections 51 and 52 Marc Smith and Jim Ten Eyck Spring 2008.
Data Structures: Lists i206 Fall 2010 John Chuang Some slides adapted from Glenn Brookshear, Brian Hayes, or Marti Hearst.
Stack Implementations Chapter 22 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
Stack: Linked List Implementation Push and pop at the head of the list New nodes should be inserted at the front of the list, so that they become the top.
Chapter 7 Queues. © 2005 Pearson Addison-Wesley. All rights reserved7-2 The Abstract Data Type Queue A queue –New items enter at the back, or rear, of.
Summary of lectures (1 to 11)
TCSS 342, Winter 2005 Lecture Notes
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 13: Queues and Vectors.
Queues. From last time: Java's built-in java.util.Stack class Consider the javadoc for Java’s built-in java.util.Stack class (
1 Lecture 26 Abstract Data Types – IV Overview  The List ADT  Implementing Stacks as Linked List  Linked List Implementation of Queues .  Preview:
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
Algorithms and Data Structures Representing Sequences by Arrays and Linked Lists.
Tutorial 5 Linked List Variations, Stack, & Queue.
© 2006 Pearson Addison-Wesley. All rights reserved7A-1 Chapter 7 Stacks.
Chapter 7 Stacks II CS Data Structures I COSC 2006
Stack and Queue.
Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04.
© 2006 Pearson Addison-Wesley. All rights reserved8 A-1 Chapter 8 Queues (slightly modified by Dan Fleck)
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part R1. Elementary Data Structures.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 4 Prepared by İnanç TAHRALI.
© 2006 Pearson Addison-Wesley. All rights reserved8 A-1 Chapter 8 Queues.
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 Chapter 7 Stacks and Queues. 2 Stack ADT Recall that ADT is abstract data type, a set of data and a set of operations that act upon the data. In a stack,
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’
Mohammad Amin Kuhail M.Sc. (York, UK) University of Palestine Faculty of Engineering and Urban planning Software Engineering Department Computer Science.
Lists, Stacks and Queues in C Yang Zhengwei CSCI2100B Data Structures Tutorial 4.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
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.
UNIVERSAL COLLEGE OF ENGG. AND TECH. 3 RD IT. QUEUE ( data structure)
Chapter 8 Queues. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 The Abstract Data Type Queue A queue –New items enter at the back, or rear, of.
1 Lecture 21: Binary Search Tree delete etc. operations Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science.
© 2011 Pearson Addison-Wesley. All rights reserved 8 B-1 Chapter 8 (continued) Queues.
CSE 373: Data Structures and Algorithms Lecture 2: Queues.
April 27, 2017 COSC Data Structures I Review & Final Exam
1 CompSci 105 SS 2005 Principles of Computer Science Lecture 9: Implementing ADTs Lecturer: Santokh Singh Please try to Understand All concepts involved.
3/3/20161 Stacks and Queues Introduction to Data Structures Ananda Gunawardena.
Lecture 21 Data Structures, Algorithms and Complexity Stacks and Queues GRIFFITH COLLEGE DUBLIN.
Chapter 7 A Queues. © 2004 Pearson Addison-Wesley. All rights reserved7 A-2 The Abstract Data Type Queue A queue –New items enter at the back, or rear,
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!
Queue ADT for lining up politely. COSC 2006 queue2 Queue – simple collection class  first-in first-out (FIFO) structure insert new elements at one end.
 In general, Queue is line of person waiting for their turn at some service counter like ticket window at cinema hall, at bus stand or at railway station.
1 Lecture 9: Stack and Queue. What is a Stack Stack of Books 2.
Chapter 7 Stacks © 2006 Pearson Addison-Wesley. All rights reserved 7A-1.
Queues Chapter 8 (continued)
Data Abstraction & Problem Solving with C++
QueueStack CS1020.
CC 215 Data Structures Queue ADT
Linked List Stacks, Linked List Queues, Dequeues
Chapter 15 Lists Objectives
Csc 2720 Data structure Instructor: Zhuojun Duan
Stacks and Queues.
Queues Queues Queues.
Stack Implementations
Chapter 8 Queues © 2006 Pearson Addison-Wesley. All rights reserved.
17CS1102 DATA STRUCTURES © 2016 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS.
Queues cont. Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
Queues Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
Chapter 7 © 2011 Pearson Addison-Wesley. All rights reserved.
Queues.
Presentation transcript:

1 Lecture 14: Queues Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science

2 Test Information on Course Web Page. See the “Test and Exams” Section. Please try not to be late for classes.

3 Tail References Beer Wine Milk head Textbook, pp. 186 tail What is the advantage of having a “tail”?

4 Linked Lists Inserting and Deleting Elements Implementing the ADT List Compared to Arrays Passing Linked Lists as Parameters Variations of the Linked List Tail References Circular Linked Lists Dummy Head Nodes

5 Circular Linked Lists Beer Wine Milk list (head) Textbook, pp. 187ff How do you get the first Node here if the external reference “list” shown above references the last Node? – pg 188.

6 Linked Lists Inserting and Deleting Elements Implementing the ADT List Compared to Arrays Passing Linked Lists as Parameters Variations of the Linked List Tail References Circular Linked Lists Dummy Head Nodes

7 Textbook, pp. 189ff Wine Milk head What is the advantage of having a Dummy Head?

8 List ADT Linked List Array

9 List ADT Linked List Array SortedList ADT Linked List Array

10 List ADT Linked List Array SortedList ADT Linked List Array Stack ADT Linked List Array List ADT

11 Stacks Basic ADT Operations Application: Undo Operations Application: Balancing Parenthesis Array Implementation Linked List Implementation Stack ADT implemented with List ADT

12 Undo Operations

13 Undo Operations

14 Stack ADT

15 Stack ADT Push Pop

16 Stack ADT void createStack ( ) void isEmpty ( ) void push ( Object newItem ) Object pop () void popAll () Object peek () Textbook, p. 252

17 Stacks Basic ADT Operations Application: Undo Operations Application: Balancing Parenthesis Array Implementation Linked List Implementation Stack ADT implemented with List ADT

18 Balancing Parenthesis ( a { b ( ) } ) { a [ b ( c ) d ( ) ) ] } Textbook, pp. 254ff

19 Stacks Basic ADT Operations Application: Undo Operations Application: Balancing Parenthesis Array Implementation Linked List Implementation Stack ADT implemented with List ADT

20 Array Implementation items: top: Java Code, Textbook, pp. 260ff

21 Stacks Basic ADT Operations Application: Undo Operations Application: Balancing Parenthesis Array Implementation Linked List Implementation Stack ADT implemented with List ADT

22 Linked List Implementation top Java Code, Textbook, pp. 263ff

23 ADT List Implementation Java Code, Textbook, pp. 263ff

24 Queues Basic ADT Queue Operations "Circular" Array Implementation Linked List Implementation "Circular" Linked List Implementation Queue ADT implement with List ADT

25 Queue

26 Queue

27 Queue ADT void createQueue ( ) void isEmpty ( ) void enqueue ( Object newItem ) Object dequeue () void dequeueAll () Object peek () Textbook, p. 299