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.

Slides:



Advertisements
Similar presentations
Data Structures Through C
Advertisements

Stacks, Queues, and Linked Lists
Stack & Queues COP 3502.
ADVANCED DATA STRUCTURES AND ALGORITHM ANALYSIS Chapter 3 Lists, Stacks, and Queues.
1 Stack and Queue. 2 Stack In Out ABCCB Data structure with Last-In First-Out (LIFO) behavior.
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.
CS 206 Introduction to Computer Science II 03 / 04 / 2009 Instructor: Michael Eckmann.
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.”
 Abstract Data Type Abstract Data Type  What is the difference? What is the difference?  Stacks Stacks  Stack operations Stack operations  Parsing.
Queues and Priority Queues
Chapter 13 Queues and Priority Queues CS Data Structures Mehmet H Gunes Modified from authors’ slides.
CS102 – Data Structures Lists, Stacks, Queues, Trees, Hash Collections Framework David Davenport Spring 2002.
CS 106 Introduction to Computer Science I 12 / 11 / 2006 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 15 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 26 / 2009 Instructor: Michael Eckmann.
CHAPTER 6 Stacks. 2 A stack is a linear collection whose elements are added and removed from one end The last element to be put on the stack is the first.
TCSS 342, Winter 2005 Lecture Notes
CS 106 Introduction to Computer Science I 12 / 13 / 2006 Instructor: Michael Eckmann.
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.
Objectives of these slides:
Queues and Priority Queues
CSE 221/ICT221 Analysis and Design of Algorithms Lecture 06: CSE 221/ICT221 Analysis and Design of Algorithms Lecture 06: Analysis of Algorithm using List,
Week7 Stack Data Structures & Algorithms. Introduction to Stacks and Queues Widely used data structures Ordered List of element Easy to implement Easy.
Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04.
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.
CSC 202 Analysis and Design of Algorithms Lecture 06: CSC 202 Analysis and Design of Algorithms Lecture 06: Analysis of Algorithm using List, Stack and.
Stacks and Queues Introduction to Computing Science and Programming I.
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 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,
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Stacks And Queues Chapter 18.
CS102 – Data Structures Lists, Stacks, Queues, Trees & HashTables. David Davenport.
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.
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.
Computer Engineering Rabie A. Ramadan Lecture 6.
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.
3/3/20161 Stacks and Queues Introduction to Data Structures Ananda Gunawardena.
STACKS & QUEUES for CLASS XII ( C++).
Queues Chapter 8 (continued)
Comprehensive Introduction to OOP with Java, C. Thomas Wu Stack ADT
Review Array Array Elements Accessing array elements
Data Structure By Amee Trivedi.
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
Homework 4 questions???.
Objectives In this lesson, you will learn to: Define stacks
Stacks and Queues.
Queues Queues Queues.
Visit for more Learning Resources
Stack and Queue.
Stacks and Queues.
Building Java Programs
CMSC 341 Lecture 5 Stacks, Queues
Stacks and Queues.
Stacks, Queues, and Deques
Infix to Postfix Conversion
CSC 143 Stacks [Chapter 6].
Stacks and Queues 1.
Data Structures and Algorithms for Information Processing
Chapter 8 Queues © 2006 Pearson Addison-Wesley. All rights reserved.
Stack.
Stacks and Queues.
Presented by : Aman Gupta PGT CS KV No.1, Narimedu, Madurai
Lecture 9: Stack and Queue
DATA STRUCTURES IN PYTHON
CMPT 225 Lecture 8 – Queue.
Data Structures & Programming
Presentation transcript:

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 postfix expressions Translating infix notation to postfix notation Activation records Solving problems involving backtracking, e.g finding a path through a maze; solving the n-queens problem

Stack Stack Operations push( ) - put a new item on top of a stack. pop( ) - get the topmost item from the stack and remove it from the stack. peek( ) -get the value of the topmost item from the stack, but do not remove the item from the stack. isEmpty( ) - return true if the stack is empty size ( ) - return the number of items on the stack

Stack Implementation May be implemented using either an array a linked list

Queue A queue is a linear data structure in which elements are inserted at one end and removed from the other end. Typically, these two ends are called the front and rear, respectively and are maintained via references to the front and rear. Enforces first-in-first-out (FIFO) behavior. The conceptual picture of a queue is that of a waiting line; for example, cars forming a line at a toll booth, or people waiting in line at a bank, or jobs waiting to be serviced by a computer.

Queue Uses of Queues Queues are often used to buffer data that is being sent from a fast computer component to another component. e.g. a print spooler. in simulation programs in operating systems Radix sorting

Queue Queue Operations enqueue( )/insert () - add an item at the rear of the queue dequeue()/getFront() get the item from the front of the queue and remove it from the queue. is_empty( ) return true if the queue is empty size ( ) return the number of items in the queue.

Queue Implementation Implementation A queue can be implemented using either a circular array a linked list