Comprehensive Introduction to OOP with Java, C. Thomas Wu Stack ADT

Slides:



Advertisements
Similar presentations
Copyright © 2012 Pearson Education, Inc. Chapter 18: Stacks And Queues.
Advertisements

Stacks. What is a stack? Last-in first-out data structure (LIFO) New objects are placed on top Removal restricted to top object Examples?
Stacks CS-240 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed in reverse.
Stack Implementations Chapter 22 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
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.
Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04.
ICOM 4035 – Data Structures Lecture 9 – Stack ADT Manuel Rodriguez Martinez Electrical and Computer Engineering University of Puerto Rico, Mayagüez ©Manuel.
Stacks and Queues Introduction to Computing Science and Programming I.
Pointers, Stacks and Memory Addressing Computer Science and Programming Concepts.
CSE 373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks; Eclipse.
Stacks And Queues Chapter 18.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 18 List ADT Animated Version.
3/3/20161 Stacks and Queues Introduction to Data Structures Ananda Gunawardena.
CSE 373 Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks; Eclipse.
Chapter 4 ADTs Stack and Queue. 4-2 Formal ADT Specifications The Java interface construct lets us collect together method interfaces into a syntactic.
Click to edit Master text styles Stacks Data Structure.
Sections 3.4 Formal Specification
Stack: a Linked Implementation
Introduction to Algorithms Second Edition by
Introduction to Algorithms Second Edition by
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.
Stacks and Queues Chapter 4.
Stacks.
Stacks and Queues.
Copyright © The McGraw-Hill Companies, Inc
Building Java Programs
Stacks Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Stacks.
Stack Implementations
Chapter 3 Image Slides Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Transparency A.
Introduction to Algorithms Second Edition by
Tonga Institute of Higher Education
ITEC 2620M Introduction to Data Structures
Chapter R A Review of Basic Concepts and Skills
Introduction to Algorithms Second Edition by
Copyright ©2014 The McGraw-Hill Companies, Inc
Chapter 6-2 (Book Chapter 8)
CSC 143 Stacks [Chapter 6].
Stacks: Implemented using Linked Lists
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.
Introduction to Algorithms Second Edition by
Assignment Pages: 10 – 12 (Day 1) Questions over Assignment? # 1 – 4
Introduction to Algorithms Second Edition by
Chapter R.2 A Review of Basic Concepts and Skills
Chapter 6-2 (Book Chapter 8)
Chapter 12 Image Slides Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Stack Implementations
Introduction to Algorithms Second Edition by
Introduction to Algorithms Second Edition by
Chapter 5 Foundations in Microbiology Fourth Edition
Introduction to Algorithms Second Edition by
Introduction to Algorithms Second Edition by
Title Chapter 22 Image Slides
Chapter 3 Foundations in Microbiology Fourth Edition
Stacks CS-240 Dick Steflik.
Copyright © The McGraw-Hill Companies, Inc
Introduction to Algorithms Second Edition by
Chapter 5 Stack (part 1).
CHAPTER 6 SKELETAL SYSTEM
Introduction to Algorithms Second Edition by
Abstract Data Types Stacks CSCI 240
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Chapter 3 Introduction to Physical Design of Transportation Facilities.
CMPT 225 Lecture 7 – Stack.
Chapter 4 Stacks and Queues
CMPT 225 Lecture 8 – Queue.
Stack Implementations
Introduction to Algorithms Second Edition by
Presentation transcript:

Comprehensive Introduction to OOP with Java, C. Thomas Wu Stack ADT Chapter 19 Stack ADT ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu Chapter 19 Objectives After you have read and studied this chapter, you should be able to Describe the key features of the Stack ADT Implement the List ADT using an array and linked list Develop applications using stacks Explain the key differences between the array and linked implementations of the Stack ADT ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu The Stack ADT A stack is a linearly ordered collection of elements, or items, where elements are added to and removed from the collection at the one end called the top of stack A stack is characterized as a last-in, first-out (LIFO) list In this chapter, we study the Stack ADT ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu Stack ADT Illustrated ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu Stack ADT Operations push add the designated element to the top of the stack pop remove the topmost element from the stack peek access the topmost element without removing it clear removes all elements from the stack size return the number of elements in the stack isEmpty return true if the stack is empty, otherwise return false ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu The push Operation ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu The pop Operation ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu The peek Operation ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu The clear Operation ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu The size Operation ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu The isEmpty Operation ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu The Stack Interface ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

The Array Implementation Comprehensive Introduction to OOP with Java, C. Thomas Wu The Array Implementation The full source code listing for NPSArrayStack<E> begins on page 1045 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

The Linked-List Implementation Comprehensive Introduction to OOP with Java, C. Thomas Wu The Linked-List Implementation The full source code listing for NPSLinkedStack<E> begins on page 1050 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.

Comprehensive Introduction to OOP with Java, C. Thomas Wu Stack Applications Checking HTML Tags Determine if the HTML file contains the required matching markers Maze Path Find a path between the starting and goal cells ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. © The McGraw-Hill Companies, Inc.