Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | May 2017 |
Last Sign in: | 307 Weeks Ago, 4 Days Ago |
Questions Answered: | 66690 |
Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Given a valid postfix expression, create the corresponding expression tree. Traverse this tree in inorder, preorder and postorder fashion (all three methods, both recursively and iteratively). CS2094 – Data Structures Laboratory Page 5/7 The program must support (at least) the following in the postfix expression: Binary operators: ^ – Exponentiation (Highest precedence) /, * – Division, Multiplication +, - – Addition, Subtraction (Lowest precedence) Operands: The operands are all variables, which is represented by a single lowercase English character. (a – z) Input – Output Format The only line of the input contains a valid postfix expression. (There will not be any space anywhere in the expression) Do the inorder, preorder and postorder ( recursively). Output the result of each traversal on a fresh line. For the inorder traversals, use proper parentheses also (i.e., each operator, together with its operands must be enclosed in parentheses). Sample Input/Output abc*+ Inorder: (a+(b*c)) Preorder: +a*bc Postorder: abc*+ m Inorder: m Preorder: m Postorder: m abcd^*+e- Inorder: ((a+(b*(c^d)))-e) Preorder: -+a*b^cde Postorder: abcd^*+e-
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll