Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Comprehensive Introduction to OOP with Java, C. Thomas Wu Stack ADT"— Presentation transcript:

1 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.

2 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.

3 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.

4 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.

5 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.

6 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.

7 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.

8 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.

9 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.

10 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.

11 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.

12 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.

13 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.

14 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.

15 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.


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

Similar presentations


Ads by Google