CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ Stack ◦ Queue & Priority Queue 2.

Slides:



Advertisements
Similar presentations
Data Structures Lecture 13: QUEUES Azhar Maqsood NUST Institute of Information Technology (NIIT)
Advertisements

© 2004 Goodrich, Tamassia Linked Lists1. © 2004 Goodrich, Tamassia Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data.
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.
Advanced Data Structures Chapter 16. Priority Queues Collection of elements each of which has a priority. Does not maintain a first-in, first-out discipline.
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.
© 2006 Pearson Addison-Wesley. All rights reserved8-1 Chapter 8 Queues CS102 Sections 51 and 52 Marc Smith and Jim Ten Eyck Spring 2008.
CS 206 Introduction to Computer Science II 10 / 20 / 2008 Instructor: Michael Eckmann.
Linked Lists1 Part-B3 Linked Lists. Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data structure consisting of a sequence.
1 Data Structures  We can now explore some advanced techniques for organizing and managing information  Chapter 12 of the book focuses on: dynamic structures.
COMP 110 Introduction to Programming Mr. Joshua Stough.
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.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
CS211 Data Structures Sami Rollins Fall 2004.
Summary of lectures (1 to 11)
Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 20 Lists, Stacks, Queues, and Priority.
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.
Stacks, Queues, and Deques
© 2004 Pearson Addison-Wesley. All rights reserved12-1 Chapter 12 : Collections Intermediate Java Programming Summer 2007.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 22 Lists, Stacks, Queues, and Priority.
Chapter 6.6, (event-driven simulation) Queues 1CSCI 3333 Data Structures.
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.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 5: Stacks and Queues.
CHAPTER 05 Compiled by: Dr. Mohammad Omar Alhawarat Stacks & Queues.
ISOM MIS 215 Module 3 – Stacks and Queues. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
Lists Based on content from: Java Foundations, 3rd Edition.
Main Index Contents 11 Main Index Contents Week 3 – The Vector Container.
Big Java Chapter 16.
CSS446 Spring 2014 Nan Wang.  Java Collection Framework ◦ Set ◦ Map 2.
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.
C++ STL CSCI 3110.
1 Stacks and Queues Starring: IndexOutOfBOundsException Co-Starring: NoSuchElementException.
CMSC 202 Stacks and Queues. What’s a Queue? A queue is a linear collection of homogeneous data in which items added to the queue must be placed at 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’
30 May Stacks (5.1) CSE 2011 Winter Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An.
Data structures Abstract data types Java classes for Data structures and ADTs.
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ LinkedList ◦ Set ◦ Map 2.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
CSE 501N Fall ‘09 11: Data Structures: Stacks, Queues, and Maps Nick Leidenfrost October 6, 2009.
A data structure is a type of data storage ….similar to an array. There are many data structures in Java (Stacks, Queues, LinkedList, Sets, Maps, HashTables,
COP INTERMEDIATE JAVA Data Structures. A data structure is a way of organizing a collection of data so that it can be manipulated effectively. A.
Chapter 4 Stacks and Queues © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Stacks. What is a Stack? A stack is a type of data structure (a way of organizing and sorting data so that it can be used efficiently). To be specific,
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.
1 Lecture 9: Stack and Queue. What is a Stack Stack of Books 2.
9/27/2016IT 1791 Abstraction A tool (concept) to manage complexity Hide irrelevant details; focus on the features needed Primitive date types are already.
Slides by Donald W. Smith
Comprehensive Introduction to OOP with Java, C. Thomas Wu Stack ADT
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Chapter 15 Lists Objectives
Heaps And Priority Queues
Chapter 20 Lists, Stacks, Queues, and Priority Queues
Abstraction A tool (concept) to manage complexity
Sequences 8/2/ :13 AM Linked Lists Linked Lists.
Building Java Programs
Pointers and Linked Lists
Data Structures and Database Applications Stacks in C#
Chapter 20 Lists, Stacks, Queues, and Priority Queues
Queue and Priority Queue Implementations
Chapter 14: Queue and Priority Queue Implementations
Sequences 12/8/2018 3:02 AM Linked Lists Linked Lists.
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
Data Structures and Algorithms for Information Processing
Queues cont. Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
Stacks, Queues, and Deques
Chapter 20 Lists, Stacks, Queues, and Priority Queues
Lecture 9: Stack and Queue
Presentation transcript:

CSS446 Spring 2014 Nan Wang

 Java Collection Framework ◦ Stack ◦ Queue & Priority Queue 2

 A hierarchy of interface types and classes for collecting objects. Each interface type is implemented by one or more classes. 3

 A stack remembers the order of its elements, but it does not allow you to insert elements in every position.  You can add and remove elements only at the top. 4

 A stack is a collection of elements with last- in, first-out retrieval (LIFO).  Undo feature in word processor  Run-time stack that a processor or virtual machine keeps to store the values of variable in nested methods. 5

6

7

 In a queue, you add items to one end (the tail) and remove them from the other end (the head).  A priority queue is an unordered collection that has an efficient operation for removing the element with the highest priority. (reading assignments) 8 Bus Stop front rear

 A Queue is a collection of elements with first- in first-out retrieval.  Print queue 9

 A priority queue collects elements, each of which has a priority.  Elements are retrieved according to their priority.  New elements can be inserted in any order.  Removing an element from a priority queue, the element with the most urgent priority is retrieved. 10

 Because the priority queue needs to be able to tell which element is the smallest, the added elements should belong to a class that implements the Comparable interface!!! 11

12

 Java How to Program 9 th  Chapter 7,8,9,10, 11,18,20 review questions  Big Java  Chapter 7-13,15 Review Questions 13

14

15

16

17

18

19