You are on page 1of 23
Dee Cra) Infix To Postfix Questions Latest Infix To Postfix MCO Objective Questions og ee an Eel AS Ela ere Cl Ll) DeRorros eae res euics Download App Question 1: View this Question Online > Convert the following arithmetic expression into Postfixform: A-B-D*E/F+B+*C 1. AB- DE* F/-BC++ 2. AB-DE+/F-BC+4 3. AB- DE* F/-BC+« 4. AB-DE/F*-BC++ Answer (Detailed Solution Below) Option 1: AB- DE* F/- BC ++ coaching SIT) ot a Sele] govt. exams Under One Roof Gee Ne Infix To Postfix Question 1 Detailed Solution The correct answeris option 1. © Key Points Postfix form isoperand 1 operand 2 operator Infix form isoperand 1 operator operand 2 The given infix form is A- B- D+ E/F+ B+ C A-B-DE*/F+B+C A- B- DE*F/+B«C A- B- DE*F/ + BCe AB- - DE*F/ + BC* AB- DE*F + BCs AB- DE*F/- BCx+ Thispurely depends on precedence and associativerules. Hence the correct answer is AB- DE + F/- BC + +. § Additional Information Description Ipreceden¢éperator ‘Associativity vy Parentheses (function call) h Brackets (array subscript) left-to- a Member selectionvia object name right Member selection via a pointer Postfixincrement/decrement O ** ~ [Prefix increment/decrement O **— — |Unary plus/minus . lo +> |Logical negation/bitwise complement |!ght-to- & - Cast (convert value to temporary left (ype) | value of type) Dereference & ‘Address (of operand) Determine sizein bytes on this implementation 3 */ % — |Multiplication/division/modulus Soe 4 + - Addition subtraction 5 << >> |Bitwise shift eft, Bitwise shift right cae Relational less than/lessthan or equal 6 << |to left-to- > >= [Relational greater than/areater than right F equal to : le 7 Relationalis equal to/is not equal to |ihr : left-to- 8 8 Bitwise AND ght 9 " BitwiseexclusiveOR efi: tight , ; left-to- ho l Bitwise inclusive OR rare lett-to- 1 8& Logical AND a left-to- h2 lI Logical OR fight : 7 right- to- h3 2: Ternary conditional fee Assignment Addition/ subtraction assignment Muttipication/division assignment | ant tq. h4 Modulus/bitwise AND assignment |/2P Bitwise exclusive/nclusive OR assignment Bitwise shift left/right assignment HS 7 comma (separate expressions) raat Perera ecu) Start Complete Exam Preparation Veena eae Se Giiee ieee bein jownload App Question 2: View this Question Online > Convert the pre-fix expressionto in-fix —*+ABC*DE+FG 1 (Ae 8)*c4(DHE) (FG) D Mrivcs 3. (A+B-C)*(0-E)(F+6) 4, (A+B)*C- (D*E)-(F+6) Answer (Detailed Solution Below) Option 4: (A+B)*C- (D*E)-(F+6) Infix To Postfix Question 2 Detailed Solution Option 4: (A+B)*C- (D*E)-(F+6) +AB*C - (D*E)-(F+6) +AB*C- *DE - (F+6) +AB°C-*DE - +FG a *4ABC - *DE- +FG “*FABC*DE - +FG CR Gee DRE ost —*+ABC*DE +FG ieee amu Beet Start Complete Exam Preparation CRG De eos te eee Oke acs posrce Jownload App Question Bank Exec) Question 3: View this Question Online > The following postfix expressionwith single digit operands is evaluated using a stack B239°/' 2984 51*~ (Note that * is the exponential operator) The top two elements of the stackafter the first * operator is evaluated are 1. 61 2.5,7 ) Answer (Detailed Solution Below) Option 1:6,1 Infix To Postfix Question 3 Detailed Solution 823*/23* 51 *- || Empty Push 23*/23* 51*- 8 Push 34/23*51*- 82 Push *723*51*- || 823 Pop /23*51*- — |/8 (2'3) Pop 23x513- 88 Push 38518. 1 - Push *51*- 123 Pop s1t- 1 (283 Push S1*- 16 The top two elements of the stackafter the first * operator is evaluated are 6, 1 ieee anu Rect Start Complete Exam Preparation ele nee ee Diesel Creer pxettiz2 Jownload App Question 4: View this Question Online > Choose the equivalent prefix form of the following expression (at (0- o))*((d- e)AF+ 9 Sh) 1. *+a- be/- de - +fgh RoC RR io 2. _* +fgh 3. *+a- be /- ed + -fgh 4, *4ab - ¢/- ed + -fgh Answer (Detailed Solution Below) Option 1:* +a - be /- de - +fgh Infix To Postfix Question 4 Detailed Solution Using the precedence rule of operator and Stackimplementation of it (a+ @ ~e))* (d- e)/f+ 9 - h)) (a + -be) *(d- e+ g- h)) 4a-be *((d- e)/(f+ g - h)) +a-be *(-de/ (f+ - h)) ~ +a-be *(-de /(+fg - h)) +a-be *(-de /-+fgh) ta-be */-de -+fgh “ta-be /-de -+fgh Option 1 matcheswith it Top Infix To Postfix MCQ O! uestions Penns ee Git Ciera Download App Question 5 $j View this Question Online > Convert the pre- fix expression to in-fix —*+ABC*DE+FG 1. (A- B)'C+(D*E)-(F+G) 2. (A+B)*C-(D-E)(F-S) 3. (AtB-C)*(D-E)*(F+G) 4, (A+B)*C- (D*E)-(F+6) Answer (Detailed Solution Below) Option 4: (A+B)*C- (D*E)-(F+G) Infix To Postfix Question 5 Detailed Solution Option 4: (A+B)*C- (0*E)(F+6) ~ +AB°C - (D°E)-(F+6) +AB°C-*DE - (F+6) +AB"C - *DE - +FG *4ABC - *DE- +FG ~*tABC *DE - +FG —*+ABCYDE +FG Ee aL eco Sela me) (Ce clin Elen obese Mock Tests ive ened a ere a Ga Jownload App aoe oa Choose the equivalent prefix form of the following expression (a+ (b- o))*(d- ef + 9 - h)) 1. *4a- be/- de - +fgh, Ne 3. *+a- be/- ed+ -foh / de —#fgh 4. *4ab -c/- ed + -fgh Answer (Detailed Solution Below) Option 1:*+a - be /- de - +fgh Infix To Postfix Question 6 Detailed Solution Using the precedence rule of operator and Stackimplementation of it (a+ @-¢))* (- e)/(F+ 9 - h)) (a + -be) *((d - e/(F+ g - h)) ta-be *(d- e)/(f+ g - h)) tarbe *(-de/(f+9 - h)) abe *(-de /(+fg -h)) +a-be *(-de /-+fgh) 4a-be */-de -+fgh \Viewthis Question Online > *ta-be /-de -+fgh Option 1 matcheswith it & Teese tc Elam Ce elim lel Pears ee rr Cee aOR esc Download App Question 7 ‘View this Question Online > The following postfix expressionwith single digit operands is evaluated using a stack B23"*/ 23*+51*- (Note that * is the exponential operator) The top two elements of the stackafter the first * operator is evaluated are 1.61 25,7 ~ 445 Answer (Detailed Solution Below) Option 1:6,1 Infix To Postfix Question 7 Detailed Solution (Operation || Expression |] Stack 823 /23* 51*-|| Empty | Push 23*/23* 51*- 8 Push 34/23" S1%= 82 Push */23*51*- || 823 Pop /23*51*- [8 (2"3) | Pop 23*51*- ‘~ Push 37515: 12 Push *51*- 123 Pop ST = 1 (2*3) Push 51 16 The top two elements of the stackafter the first * operator is evaluated are 6, 1 Pn CR ABU Re ll Re Le Start Complete Exam Preparation Pea end Mock Tests Question Bank pre Question 8: View this Question Online > Convert the pre-fix expression to in-fix —*+ABC*DE+FG 1. (A-B)*C+(0*E)F+6), a» ma E)*(F-S) 3. (A+B-C)*(0-E)"(F+6) 4, (A+B)*C- (D*E)-(F+6) Answer (Detailed Solution Below) Option 4: (A+B)*C- (D*E)-(F+6) Infix To Postfix Question 8 Detailed Solution Option 4: (A+B)*C- (D*E)-(F+6) +AB*C - (D°E)-(F+6) +AB°C- *DE - (F+6) +AB°C-*DE - +FG *4ABC - *DE - +FG -*+ABC*DE - +7G. ~*+ABCADE +FG ire rere) Pela CM cima yeh iced) iG) Po faba Ss oes cielo Creston Jownload App Erie Question 9: View this Question Online > Convert the following arithmetic expression into Postfixtorm: A-B-D*E/F+B+C 1. AB- DE* F/-BC++ SORE etc 2. AB-DE*/F-BC*+ 3. AB- DE* F/-BC+« 4. AB- DE/F*-BC*+ Answer (Detailed Solution Below) om Option 1: AB- DE * F/- BC NA G Infix To og led Solution RO option 1. oints ix form isoperand 1 operand 2 operator Infix form isoperand 1 operator operand 2 The given infix form is A- B-D + E/F+B+C A-B-DE*/F+B+C A. B- DE*F/+B«C A- B- DE*F/ + BC AB. - DE*F/ + BCs AB- DE*F + BC+ AB- DE*F/- BC+ This purely depends on precedence and associativerules. ‘the correct answer is A9- DE« F/- BC« +. & Additional_Information Description init i Parentheses(function call) h Brackets (array subscript) left-to- Member selectionvia objectname right Member selection via a pointer Postfixincrement/decrement Relational greater than/greater than jor equal to Relational is equal to/is not equal to ++ — [Prefix increment/decrement ++ |Unary plus/minus . 2 ir Logical negation/bitwise complement |"ight-to- pas Cast(convert value to temporary left (¥Pe) | value of type) Dereference & ‘Address (of operand) Determine sizein bytes on this implementation f 3 */ % |Multiplication/division/modulus < * 4 + - — |Addition/subtraction 5 << >> |Bitwiseshiftlett, Bitwiseshittr fortes Relational lessthan/lessthan or é to Is & |Bitwise AND 9 i BitwiseexclusiveOR Ho l Bitwiseinclusive OR 11 && Logical AND 112 11 Logical OR vs rright-to- 3 Temary conditional ea Assignment ‘Addition/ subtraction assignment Multiplication/division assignment | isnt. to- 114 \Modulus/bitwise AND assignment en \Bitwise exclusiveAnclusive OR assignment Bitwise shift left/right assignment ; ; left-to- H5 Comma (separate expressions) fight ieee amu Beetle Start Complete Exam Preparation Oat eed eas Cres Gage jownload App Question 10: View this Question Online > Consider the following translation scheme S-P P= (orint(+)} P+R PR R= R*U {orintf(*)3}, R-U u U = digihfprint(digit.val)) Here, digit.val represents the corresponding numerical value. What will be the output for the input string 8 + 9* 4? 1.4*894 2.4+894* 3. 8974+ 478944 Answer (Detailed Solution Below) Option 2:+894* Infix To Postfix Question 10 Detailed Solution | Pp is ™ " Po o+ R 1 e___ gates Heneg, it will print + 894* & Cg India’s #1 Learning Platform Start Complete Exam Preparation CRG Der eos Wau aces Mock Tests lad rece Question Bank oni Jownload App Question 11: View this Question Online > Choose the equivalent prefix form of the following expression (a+ (b- c))*(d- e)/f + 0 - h)) 1, *+a- be /- de - +fght 3. * 48 - be /- ed + ~fgh /de~¥igh 4, *4ab -c/- ed + -fgh Answer (Detailed Solution Below) Option 1:*+a - be /- de - +fgh Infix To Postfix Question 11 Detailed Solution SED iene ST RE Te aE TTAT ROC SoC MTT RR NCR SRT INTO EO TR ST Ore STE EE (a+ @-c))* (d- e/if+ 9 - h)) (a + ~be) *((d- ey/(f+ 9 - hy) ta-be *(d-e)/(f+ 0 - h)) ta-be *(-de/(f+g - h)) ~ 4a-be *(-de /(+fg -h)) +a-be *(-de /-+fgh) ta-be “/de -4+fgh *ta-be /-de -+fah Option 1 matcheswith it Teer Eee Oe aR rae Start Complete Exam Preparation Pan mo Mock Tests Git ee oo Download App Question 12: View this Question Online > What is the postfix expression of the given infix expression :a + b¥c - d/g? 1. abcdg/-*+ 2. abe*+dg/- 3. abe+*dg/- 4, abe*dg/-+ Answer (Detailed Solution Below) Option 2: abe*+dg/- Infix To Postfix Question 12 D je Suton Concept: oot Infix e9 pression of the form a op b. When an operator is in-betwean every pair of operand: Pe nm: The expressionof the form ab op. When an operator is followed for every pair s. = 1. Scan the infix expression from left to right. 2. If the scanned characteris an operand, output it 3. Else, + If the precedence of the scanned operator is greater than the precedence of the operator in the stack(orthe stackis empty or the stack contains a (), push it. + Else, Pop all the operators from the stackwhich are greater than or equal to in precedence than that of the scanned operator. After doing that Push the scanned operator to the stack (If you encounter parenthesiswhile popping then stop there and push the scanned operator in the stack) 4.If the scanned characteris an ‘(, push it to the stack 5.If the scanned characteris an ‘Y, pop the steckand output it until a’ is encountered, and discard both the parenthesis. 6. Repeat steps2-6 until infix expressionis scanned. 7. Print the output 8.Pop and output from the stackuntil it isnot empty, Calculation Input expression: a+ b*c -d/g Symbol PostfixString Stack : ; — — ~ Ag % ab ” c abe ” - abet+ € d abe*+d = / abe*+d ah, 9 abe*+dg t abo*+dg/- Output expression:abe*+dg/- Shortcut Trick Evaluate as per precedence and associativity a+ bre -d/g =a +bet-d/g =a+tbet —dg/ = abe*+ -dg/ = abet dg/- ieee anu Beet Start Complete Exam Preparation Pea recy a) to) DB Download App OR Gee ans Question 13: cO View this Question Online > The prefix equivalent of the folloy fix expressionis: “eS 1 Ye ac -t+/abc*de*tac 3. +--/abe*detac 4.-+/abc-*detac Answer (Detailed Solution Below) Option 1:-+-/ abc*de*ac Infix To Postfix Question 13 Detailed Solution Algorithm for conversion from prefix to infix: ‘STEP 1: Startscanning the expression from RHS. Push the operators on the top of th only high priority operator can be pushed over a low priority operator. ‘STEP 2: Ifa low priority operator is encountered in expression a then pop it and after that push low priority operator STEP 3: XS Print each operand. Given expressionis :a/b -c+ d*e-a*c = /ab-c+d*e-a*c = -/abe+d*e-ate = +-/abcd*e-a*c = +-/ abe*de-atc is high priority operator, cn = +/aborde-*ac = -+/ abc*de*ac & ieee anu Bec ly Start Complete Exam Pr RC oer Pea Practice Dag Cresco Brot. Question 14: View this Question Online > The following postiix expressionwith single- 527% *3913/-911*+ igit operands in evaluated using a stack Note that “ is exponentiation operator, * is multiplication operator, / is division operator, + is addition operator and — is subtraction operator Answer (Detailed Solution Below) 736 Infix To Postfix Question 14 Detailed Solution 527% *3913/-911*+ Push:5, 2 and 7 5 2 7 Pop:2 and 7 BD orc operation 2° 7= 128 Push: 128 5 128 queen eee: ae Perform operation: 5 * 128 = 640 Push: 640 Also push: 39 and 13 640 | 39 13 Pop: 7 and 14 Perform operation: 39/13 = 3 Push:2 640 | 3 Pop: 640 and 3 Perform operation: 640 - 3 = 637 Push: 637 Also push: 7 and 5 637 | 9 | 11 Pop:9 and 11 Perform operation: 9 x 11= 35 Push:35 637 | 99 Pop: 637 and 99 Perform operation: 637 + 99 = 736 Push:161 736 After evaluating: 736 is present onto the stack Hence 161 is the answer for the given postfix operation.

You might also like