logging in or signing up infix to postfix pankajgiri Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 15 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: February 10, 2012 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Infix to postfix conversion: Infix to postfix conversion Read the tokens from a vector infixVect of tokens (strings) of an infix expression When the token is an operand Add it to the end of the vector postfixVect of token (strings) that is used to store the corresponding postfix expression When the token is a left or right parenthesis or an operator If the token x is “(“ Push_back the token x to the end of the vector stackVect of token (strings) that simulates a stack if the token x is “)” Repeatedly pop_back a token y from stackVect and push_back that token y to postfixVect until “(“ is encountered in the end of stackVect. Then pop_back “(“ from stackVect. If stackVect is already empty before finding a “(“, that expression is not a valid expression. if the token x is a regular operator Step 1 : Check the token y currently in the end of stackVect. Step 2 : If (case 1) stackVect is not empty and (case 2) y is not “(“ and (case 3) y is an operator of higer or equal precedence than that of x, then pop_back the token y from stackVect and push_back the token y to postfixVect, and go to Step 1 again . Step 3 : If (case 1) stackVect is already empty or (case 2) y is “(“ or (case 3) y is an operator of lower precedence than that of x, then push_back the token x into stackVect. When all tokens in infixVect are processed as described above, repeatedly pop_back a token y from stackVect and push_back that token y to postfixVect until stackVect is emptyInfix to postfix conversion: infixVect postfixVect ( a + b - c ) * d – ( e + f ) Infix to postfix conversionInfix to postfix conversion: infixVect postfixVect a + b - c ) * d – ( e + f ) ( stackVect Infix to postfix conversionInfix to postfix conversion: infixVect postfixVect + b - c ) * d – ( e + f ) ( a Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect b - c ) * d – ( e + f ) ( a + Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect - c ) * d – ( e + f ) ( a b + Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect c ) * d – ( e + f ) ( a b + - Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect ) * d – ( e + f ) ( a b + c - Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect * d – ( e + f ) a b + c - Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect d – ( e + f ) a b + c - * Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect – ( e + f ) a b + c - d * Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect ( e + f ) a b + c – d * - Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect e + f ) a b + c – d * - ( Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect + f ) a b + c – d * e - ( Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect f ) a b + c – d * e - ( + Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect ) a b + c – d * e f - ( + Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect a b + c – d * e f + - Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect a b + c – d * e f + - Infix to postfix conversion stackVect You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
infix to postfix pankajgiri Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 15 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: February 10, 2012 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Infix to postfix conversion: Infix to postfix conversion Read the tokens from a vector infixVect of tokens (strings) of an infix expression When the token is an operand Add it to the end of the vector postfixVect of token (strings) that is used to store the corresponding postfix expression When the token is a left or right parenthesis or an operator If the token x is “(“ Push_back the token x to the end of the vector stackVect of token (strings) that simulates a stack if the token x is “)” Repeatedly pop_back a token y from stackVect and push_back that token y to postfixVect until “(“ is encountered in the end of stackVect. Then pop_back “(“ from stackVect. If stackVect is already empty before finding a “(“, that expression is not a valid expression. if the token x is a regular operator Step 1 : Check the token y currently in the end of stackVect. Step 2 : If (case 1) stackVect is not empty and (case 2) y is not “(“ and (case 3) y is an operator of higer or equal precedence than that of x, then pop_back the token y from stackVect and push_back the token y to postfixVect, and go to Step 1 again . Step 3 : If (case 1) stackVect is already empty or (case 2) y is “(“ or (case 3) y is an operator of lower precedence than that of x, then push_back the token x into stackVect. When all tokens in infixVect are processed as described above, repeatedly pop_back a token y from stackVect and push_back that token y to postfixVect until stackVect is emptyInfix to postfix conversion: infixVect postfixVect ( a + b - c ) * d – ( e + f ) Infix to postfix conversionInfix to postfix conversion: infixVect postfixVect a + b - c ) * d – ( e + f ) ( stackVect Infix to postfix conversionInfix to postfix conversion: infixVect postfixVect + b - c ) * d – ( e + f ) ( a Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect b - c ) * d – ( e + f ) ( a + Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect - c ) * d – ( e + f ) ( a b + Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect c ) * d – ( e + f ) ( a b + - Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect ) * d – ( e + f ) ( a b + c - Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect * d – ( e + f ) a b + c - Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect d – ( e + f ) a b + c - * Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect – ( e + f ) a b + c - d * Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect ( e + f ) a b + c – d * - Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect e + f ) a b + c – d * - ( Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect + f ) a b + c – d * e - ( Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect f ) a b + c – d * e - ( + Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect ) a b + c – d * e f - ( + Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect a b + c – d * e f + - Infix to postfix conversion stackVectInfix to postfix conversion: infixVect postfixVect a b + c – d * e f + - Infix to postfix conversion stackVect