Lecture14_stack

Lecture14_stack - Announcements 5 Read Chapter 22 & 23...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 1 Announcements Announcements 5 A3 is due Monday 11/1/04 11:59pm java.util.EmptyStackException
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 2 Last Lecture Last Lecture 5 Stack ADT Stack Implementations Uses of a Stack A3
Background image of page 2
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 3 This Lecture This Lecture 5 Use of Stacks Infix Evaluation Using a Stack Runtime Call Stack
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 4 Infix Evaluation (Basic Idea) Infix Evaluation (Basic Idea) 5 Split expr tokens into two stacks Operands on one stack Operators on other stack consider precedence of current operator and operator on  top of operator stack.  while top is higher precedence, evaluate top operator with  top two operands Push current token onto operator stack Evaluate remaining operators
Background image of page 4
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 5 Infix Evaluation Infix Evaluation 5 Result is operandStack.pop( )
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 6 Infix Evaluation Infix Evaluation 2 * 3 + 4 / 2 ^ 3 2 operands operators * 3 * if operator stack is empty, push operator
Background image of page 6
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 7 Infix Evaluation Infix Evaluation 2 * 3 + 4 / 2 ^ 3 2 operands operators * 3 3 + check precedence first * 2 perform * first = 6 6 +
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 8 Infix Evaluation Infix Evaluation 2 * 3 + 4 / 2 ^ 3 6 operands operators + 4 2 / / check precedence first
Background image of page 8
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 9 Infix Evaluation Infix Evaluation 2 * 3 + 4 / 2 ^ 3 6 operands operators + 4 2 / ^ check precedence first ^ 3
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 10
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/17/2011 for the course CS 367 taught by Professor Marvinsolomon during the Spring '08 term at Wisconsin.

Page1 / 39

Lecture14_stack - Announcements 5 Read Chapter 22 & 23...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online