1 Data Organization Example 1: A simple text editor –Store the text buffer as a list of lines. –How would we implement the UNDO operation? Example 2: Parsing.

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 and Queues. Not really data structures – More of an enforcement of policy – Can be implemented using an array or linked list – Can store just about.
Stack & Queues COP 3502.
Queues A waiting line that grows by adding elements to its end and shrinks by taking elements from its front Line at the grocery store Cars in traffic.
Stacks  a data structure which stores data in a Last-in First-out manner (LIFO)  has a pointer called TOP  can be implemented by either Array or Linked.
Fundamentals of Python: From First Programs Through Data Structures
ADT Stacks and Queues. Stack: Logical Level “An ordered group of homogeneous items or elements in which items are added and removed from only one end.”
Min Chen School of Computer Science and Engineering Seoul National University Data Structure: Chapter 4.
 Abstract Data Type Abstract Data Type  What is the difference? What is the difference?  Stacks Stacks  Stack operations Stack operations  Parsing.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Unit : Overview of Queues.
Queues and Priority Queues
Chapter 13 Queues and Priority Queues CS Data Structures Mehmet H Gunes Modified from authors’ slides.
1 Queues CPS212 Gordon College. 2 Introduction to Queues A queue is a waiting line – seen in daily life –Real world examples – toll booths, bank, food.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
1 Data Structures  We can now explore some advanced techniques for organizing and managing information  Chapter 12 of the book focuses on: dynamic structures.
Queues Chapter 8 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved
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.
© 2004 Pearson Addison-Wesley. All rights reserved12-1 Chapter 12 : Collections Intermediate Java Programming Summer 2007.
ADT Stacks and Queues. Stack: Logical Level “An ordered group of homogeneous items or elements in which items are added and removed from only one end.”
DS.L.1 Lists, Stacks, and Queues (Review) Chapter 3 Overview Abstract Data Types Linked Lists, Headers, Circular Links Cursor (Array) Implementation Stacks.
Queues and Priority Queues
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)
Stacks and Queues Introduction to Computing Science and Programming I.
Adapted from instructor resources Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights.
September 05 Kraemer UGA/CSCI 2720 Lists – Part I CSCI 2720 Eileen Kraemer The University of Georgia.
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.
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,
Week 3 - Friday.  What did we talk about last time?  Stacks  Array implementation of a stack.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Data Structures Chapter 6. Data Structure A data structure is a representation of data and the operations allowed on that data. Examples: 1.Array 2.Record.
© 2011 Pearson Addison-Wesley. All rights reserved 8 B-1 Chapter 8 (continued) Queues.
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.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Stacks A stack is a linear data structure that can be accessed only at one of its ends for storing and retrieving data LIFO (Last In First Out) structure.
Stacks and Queues CMSC 201. Stacks and Queues Sometimes, when we use a data-structure in a very specific way, we have a special name for it. This is to.
Lecture 10 b Stacks b Queues. 2 Stacks b A stack ADT is linear b Items are added and removed from only one end of a stack b It is therefore LIFO: Last-In,
Click to edit Master text styles Stacks Data Structure.
Data Structures Intro2CS – week Stack ADT (Abstract Data Type) A container with 3 basic actions: – push(item) – pop() – is_empty() Semantics: –
Stack ADT (Abstract Data Type) N …
Queues Chapter 8 (continued)
Review Array Array Elements Accessing array elements
G.PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY
Data Structure By Amee Trivedi.
G64ADS Advanced Data Structures
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.
Lecture 7 Queues Stacks Trees.
COSC160: Data Structures: Lists and Queues
Chapter 15 Lists Objectives
Stacks and Queues.
Queues Chapter 8 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved
Chapter 13 Queues and Priority Queues
Introduction to Data Structure
Data Structures and Database Applications Queues in C#
Building Java Programs
CMSC 341 Lecture 5 Stacks, Queues
Principles of Computing – UFCFA3-30-1
structures and their relationships." - Linus Torvalds
Queues.
Stacks, Queues, and Deques
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.
Container classes, ADTs
Stacks and Queues CSE 373 Data Structures.
QUEUE Visit for more Learning Resources Free Powerpoint Templates.
CS210- Lecture 6 Jun 13, 2005 Announcements
CSCS-200 Data Structure and Algorithms
Queues.
Chapter 4 Stacks and Queues
CMPT 225 Lecture 8 – Queue.
Presentation transcript:

1 Data Organization Example 1: A simple text editor –Store the text buffer as a list of lines. –How would we implement the UNDO operation? Example 2: Parsing –How does the compiler check the syntax? Example 3: Bracket matching Example 4: Runtime storage organization

2 Stack ADT Data –A collection of homogeneous elements arranged in a sequence. –LIFO structure Operations –Push –Pop –Top –isEmpty

3 Stack ADT Implementation –Contiguous memory Which end of the array is the top of the stack? –Linked memory Which end of the "list" is the top of the stack?

4 Data Organization Example 1: Discrete Event Simulation –Bank waiting line Each new customer joins the end of the line The next customer to walk up to a teller is the one at the front of the line Run a sim to process arrival and departure events and collect information about waiting times. Example 2: Process scheduling –Round-robin

5 Queue ADT Data –A collection of homogeneous elements arranged in a sequence. –FIFO structure Operations –Enqueue –Dequeue –Front –isEmpty

6 Queue ADT Implementation –Contiguous memory Which end of the array is the front/end? –Linked memory Which end of the "list" is the front?

7 A different kind of queue Queues are used to model waiting lines. In some situations (e.g. aircraft boarding), certain elements in a line (e.g. first class passengers) have a higher priority: the FIFO model is not strictly applicable. We need a data structure similar to a queue, where elements are ordered, not based on arrival, but based on some priority.

8 Priority queue I Data –A collection of elements, where each element is assigned a priority Efficient extraction of the highest-priority element should be supported. Operations –Enqueue –Dequeue –GetMax Implementation –How would you modify your regular queue implementation?