Presentation is loading. Please wait.

Presentation is loading. Please wait.

Stacks, Queues, and Deques

Similar presentations


Presentation on theme: "Stacks, Queues, and Deques"— Presentation transcript:

1 Stacks, Queues, and Deques
Chapter 6

2 Object Class Hierarchy

3 Stacks Array version Linked-list version applications

4 Stacks A last-in, first-out or LIFO data structure
Basic operations: Push, Pop and Top

5 Basic Stack Operations

6 Stack Class Definition

7 Stack as Array

8 Constructor, Destructor and Purge() member functions

9 Push() Pop() and Top()

10 Accept()

11 Iterator

12 Iter class member function definition

13 Stack as Linked List

14 Constructor, Destructor and Purge() member functions

15 Push() Pop() and Top()

16 Accept()

17 Iterator

18 Application Infix Notation: binary operands appear in between their operands. (5+9)*2+6*5 Prefix Notation: (polish notation) binary operators precede their operands. No parenthesis needed. + * * 6 5 + ( * ( + ( 5 , 9 ) , 2 ) , * ( 6 , 5 ) Postfix Notation: binary operators follow their operands. No parenthesis needed. * 6 5 * +

19 Evaluating Postfix Expressions

20 Evaluating Postfix Expression
* 6 5 * +

21 Implementation


Download ppt "Stacks, Queues, and Deques"

Similar presentations


Ads by Google