ch3-2-StackApplication - More Stack Applications...

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

View Full Document Right Arrow Icon
More Stack Applications Parentheses Matching Maze Router Infix to Postfix
Background image of page 1

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

View Full DocumentRight Arrow Icon
Parentheses Matching ( ( ( a+b ) *c+d-e ) / ( f+g ) - ( h+j ) * ( k-l ) ) /(m-n) Output pairs (u,v) such that the left parenthesis at position u is matched with the right parenthesis at v . (2,6) (1,13) (15,19) (21,25) (27,31) (0,32) (34,38) ( a+b ) ) *( ( c+d ) (0,4) right parenthesis at 5 has no matching left parenthesis (8,12) left parenthesis at 7 has no matching right parenthesis
Background image of page 2
Parentheses Matching scan expression from left to right when a left parenthesis is encountered, add its position to the stack when a right parenthesis is encountered, remove matching position from 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
Example ( ( ( a+b ) *c+d-e ) / ( f+g ) - ( h+j ) * ( k-l ) ) /(m-n) 0 1 2
Background image of page 4
Example ( ( ( a+b ) *c+d-e ) / ( f+g ) - ( h+j ) * ( k-l ) ) /(m-n) 0 1 (2,6) (1,13) 15
Background image of page 5

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

View Full DocumentRight Arrow Icon
Example ( ( ( a+b ) *c+d-e ) / ( f+g ) - ( h+j ) * ( k-l ) ) /(m-n) 0 1 (2,6) (1,13) (15,19) 21
Background image of page 6
Example ( ( ( a+b ) *c+d-e ) / ( f+g ) - ( h+j ) * ( k-l ) ) /(m-n) 0 1 (2,6) (1,13) (15,19) (21,25) 27
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/13/2011 for the course DATA STRUC 101 taught by Professor Hansanyong during the Spring '11 term at 한동대학교.

Page1 / 32

ch3-2-StackApplication - More Stack Applications...

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

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