# Application of Stack MCQs

Q1. Identify the infix expression from the list of options given below..

A. a/b+(c-d).

B. abc*+d+ab+cd+*ce-f-.

C. ab-c-.

D. "+AB".

Q2. Which of the following statement is incorrect with respect to evaluation of infix expression algorithm?.

A. Operand is pushed on to the stack.

B. If the precedence of operator is higher, pop two operands and evaluate.

C. If the precedence of operator is lower, pop two operands and evaluate.

D. The result is pushed on to the operand stack.

Answer= If the precedence of operator is higher, pop two operands and evaluate

Q3. Evaluate the following statement using infix evaluation algorithm and choose the correct answer. 1+2*3-2.

A. 3.

B. 6.

C. 5.

D. 4.

Q4. Evaluation of infix expression is done based on precedence of operators..

A. TRUE.

B. FALSE.

C.  Nothing can be said.

D.  None of the mentioned.

Q5. The system throws an error if parentheses are encountered in an infix expression evaluation algorithm..

A. TRUE.

B. FALSE.

C.  Nothing can be said.

D.  None of the mentioned.

Q6. Evaluate the following and choose the correct answer.a/b+c*d where a=4, b=2, c=2, d=1..

A. 1.

B. 4.

C. 5.

D. 2.

Q7. Evaluate the following statement using infix evaluation algorithm and choose the correct answer. 4*2+3-5/5.

A. 10.

B. 11.

C. 16.

D. 12.

Q8. Using the evaluation of infix expression, evaluate a^b+c  and choose the correct answer. (a=2, b=2, c=2).

A. 12.

B. 8.

C. 10.

D. 6.

Q9. Evaluate the following infix expression using algorithm and choose the correct answer. a+b*c-d/e^f  where a=1, b=2, c=3, d=4, e=2, f=2..

A. 6.

B. 8.

C. 9.

D. 7.

Q10. How many stacks are required for evaluation of prefix expression?.

A. one.

B. two.

C. three.

D. four.

Q11. While evaluating a prefix expression, the string is read from?.

A. left to right.

B. right to left.

C. center to right.

D. center to left to right.

Q12. The associativity of an exponentiation operator ^ is right side..

A. TRUE.

B. FALSE.

C.  Nothing can be said.

D.  None of the mentioned.

Q13. How many types of input characters are accepted by this algorithm?.

A. one.

B. two.

C. three.

D. four.

Q14. What determines the order of evaluation of a prefix expression?.

A. precedence and associativity.

B. precedence only.

C. associativity only.

D. depends on the parser.

Q15. Find the output of the following prefix expression*+2-2 1/-4 2+-5 3 1.

A. 2.

B. 12.

C. 10.

D. 4.

Q16.  An error is thrown if the character '\n' is pushed in to the character stack..

A. TRUE.

B. FALSE.

C.  Nothing can be said.

D.  None of the mentioned.

Q17. Using the evaluation of prefix algorithm, evaluate +-9 2 7..

A. 10.

B. 4.

C. 17.

D. 14.

Q18. If -*+abcd = 11, find a, b, c, d using evaluation of prefix algorithm..

A. a=2, b=3, c=5, d=4.

B. a=1, b=2, c=5, d=4.

C. a=5, b=4, c=7,d=5.

D. a=1, b=2, c=3, d=4.

Q19. What is the other name for a postfix expression?.

A. Normal polish Notation.

B. Reverse polish Notation.

C. Warsaw notation.

D. Infix notation.

Q20. Which of the following is an example for a postfix expression?.

A. a*b(c+d).

B. abc*+de.

C. "+AB".

D. a+b-c.

Q21. Reverse Polish Notation is the reverse of a Polish Notation.

A. TRUE.

B. FALSE.

C.  Nothing can be said.

D.  None of the mentioned.

Q22. What is the time complexity of evaluation of postfix expression algorithm?.

A. O (N).

B. O (N log N).

C. O (N2).

D. O (M log N).

Q23. In Postfix expressions, the operators come after the operands..

A. TRUE.

B. FALSE.

C.  Nothing can be said.

D.  None of the mentioned.

Q24. Which of the following is not an application of stack?.

A.  evaluation of postfix expression.

B.  conversion of infix to postfix expression.

C.  balancing symbols.

D.  line at ticket counter.

Q25. While evaluating a postfix expression, when an operator is encountered, what is the correct operation to be performed?.

A. push it directly on to the stack.

B. pop 2 operands, evaluate them and push the result on to the stack.

C. pop the entire stack.

D. ignore the operator.

Answer= pop 2 operands, evaluate them and push the result on to the stack

Q26. Which of the following statement is incorrect?.

A. Postfix operators use value to their right.

B. Postfix operators use value to their left.

C. Prefix operators use value to their right.

D. In postfix expression, operands are followed by operators.

Answer= Postfix operators use value to their right

Q27. What is the result of the given postfix expression?  abc*+ where a=1, b=2, c=3..

A. 4.

B. 5.

C. 6.

D. 7.

Q28. What is the result of the following postfix expression?  ab*cd*+ where a=2,b=2,c=3,d=4..

A. 16.

B. 12.

C. 14.

D. 10.

Q29. Evaluate the postfix expression ab + cd/- where a=5, b=4, c=9, d=3..

A. 23.

B. 15.

C. 6.

D. 10.

Q30. Evaluate and write the result for the following postfix expression   abc*+de*f+g*+ where a=1, b=2, c=3, d=4, e=5, f=6, g=2..

A. 61.

B. 59.

C. 60.

D. 55.

Q31. What data structure is used when converting an infix notation to prefix notation?.

A. Stack.

B.

Que.

C. B-Trees.

Q32. What would be the Prefix notation for the given equation?A+(B*C).

A. " +a*CB ".

B. *B+AC.

C. " +a*bc ".

D. *A+CB.

Q33. What would be the Prefix notation for the given equation?(A*B)+(C*D).

A. +*AB*CD.

B. *+AB*CD.

C. **AB+CD.

D. +*BA*CD.

Q34. What would be the Prefix notation for the given equation?A+B*C^D.

A. " +a*B^CD ".

B. " +a^B*CD ".

C. *A+B^CD.

D. ^A*B+CD.

Q35. Out of the following operators (^, *, +, &, \$), the one having highest priority is _________.

A. +.

B. \$.

C. ^.

D. &.

Q36. What would be the Prefix notation for the given equation?A^B^C^D.

A. ^^^ABCD.

B. ^A^B^CD.

C. ABCD^^^.

D. AB^C^D.

Q37. What would be the Prefix notation for the given equation?(a+(b/c)*(d^e)-f).

A. -+a*/^bcdef.

B. -+a*/bc^def.

C. -+a*b/c^def.

D. -a+*/bc^def.

Q38. What would be the Prefix notation for the given equation?A+B+C.

A. ++ABC and AB+C+.

B. AB+C+ and ++ABC.

C. ABC++ and AB+C+.

D. ABC+ and ABC+.

Q39. When an operand is read, which of the following is done?.

A. It is placed on to the output.

B. It is placed in operator stack.

C. It is ignored.

D. Operator stack is emptied.

Answer= It is placed on to the output

Q40. What should be done when a left parenthesis '(' is encountered?.

A. It is ignored.

B. It is placed in the output.

C. It is placed in the operator stack.

D. The contents of the operator stack is emptied.

Answer= It is placed in the operator stack

Q41. Which of the following is an infix expression?.

A. (a+b)*(c+d).

B. ab+c*.

C. " +AB ".

D. abc+*.

Q42. Parentheses are simply ignored in the conversion of infix to postfix expression..

A. TRUE.

B. FALSE.

C.  Nothing Can be said.

D.  None of the mentioned.

Q43. It is easier for a computer to process a postfix expression than an infix expression..

A. TRUE.

B. FALSE.

C.  Nothing Can be said.

D.  None of the mentioned.

Q44. What is the postfix expression for the infix expression?a-b-c.

A. -ab-c.

B. abc-.

C. " -abc ".

D. -ab-c.

Q45. What is the postfix expression for the following infix expression?a/b^c-d.

A. abc^/d-.

B. ab/cd^-.

C. ab/^cd-.

D. abcd^/-.

Q46. Which of the following statement is incorrect with respect to infix to postfix conversion algorithm?.

A. operand is always placed in the output.

B. operator is placed in the stack when the stack operator has lower precedence.

C. parenthesis are included in the output.

D. higher and equal priority operators follow the same condition.

Answer= parenthesis are included in the output

Q47. In infix to postfix conversion algorithm, the operators are associated from?.

A. right to left.

B. left to right.

C. centre to left.

D. centre to right.

Q48. What is the corresponding postfix expression for the given infix expression?a*(b+c)/d.

A. ab*+cd/.

B.  ab+*cd/.

C. abc*+/d.

D. abc+*d/.

Q49. What is the corresponding postfix expression for the given infix expression?a+(b*c(d/e^f)*g)*h).

A. ab*cdef/^*g-h+.

B. abc*def^/g*-h*+.

C. abcd*^ed/g*-h*+.

D. abc*de^fg/*-*h+.

Q50. What would be the solution to the given prefix notation?- + 5 / 10 5 5.

A. 2.

B. 5.

C. 10.

D. 7.

Q51. What would be the solution to the given prefix notation?/ / / / 16 4 2 1.

A. 1.

B. 4.

C. 2.

D. 8.

Q52. What would be the solution to the given prefix notation?+ 9 * 3 / 8 4.

A. 14.

B. 15.

C. 18.

D. 12.

Q53. What would be the solution to the given prefix notation?- + 1 2 * 3 / 6 2.

A. 6.

B. -6.

C. 3.

D. -3.

Q54. What would be the solution to the given prefix notation?- * 1 5 / * / 6 3 6 2.

A. 1.

B. 0.

C. -1.

D. -2.

Q55. What would be the solution to the given prefix notation?* / + 1 2 / 4 2 + 3 5.

A. 12.

B. 7.5.

C. 9.

D. 13.5.

Q56. Given a prefix and a postfix notation what are the difference between them?.

A. The postfix equation is solved starting from the left whereas the prefix notation is solved from the right.

B. The postfix equation is solved starting from the right whereas the prefix notation is solved from the left.

C. Both equations are solved starting from the same side(right).

D. Both equations are solved starting from the same side(left).

Answer= The postfix equation is solved starting from the left whereas the prefix notation is solved from the right

Q57. When converting the prefix notation into an infix notation, the first step to be followed is ________.

A. Reverse the equation.

B. Push the equation to the stack.

C. Push the equation onto the queue.

D. Push the equation to the stack or queue.

Q58. The time complexity of converting a prefix notation to infix notation is _________.

A. O(n) where n is the length of the equation.

B. O(n) where n is number of operands.

C. O(1).

D. O(logn) where n is length of the equation.

Answer= O(n) where n is the length of the equation

Q59. Given two processes (conversion of postfix equation to infix notation and conversion of prefix notation to infix notation), which of the following is easier to implement?.

A. Both are easy to implement.

B. Conversion of postfix equation to infix equation is harder than converting a prefix notation to infix notation.

C. Conversion of postfix equation to infix equation is easier than converting a prefix notation to infix notation.

D. Insufficient data.

Answer= Conversion of postfix equation to infix equation is easier than converting a prefix notation to infix notation

Q60. Which of the following data structure is used to convert postfix expression to infix expression?.

A. Stack.

B.

Que.

D. Heap.

Q61. The postfix expression abc+de/*- is equivalent to which of the following infix expression.

A. abc+-de*/.

B. (a+b)-d/e*c.

C. a-(a+b)*(d/e).

D. abc+*-(d/e).

Q62. The equivalent infix expression and value for the postfix form 1 2 + 3 * 4 5 * - will be.

A. 1 + 2 * 3 - 4 * 5 and -13.

B. (2 + 1) * (3 - 4) * 5 and 13.

C. 1 + 2 * (3 - 4) * 5 and -11.

D. (1 + 2) * 3 - (4 * 5) and -11.

Answer= (1 + 2) * 3 - (4 * 5) and -11

Q63. What is the value of the postfix expression  2 3 + 4 5 6 - - *.

A. 19.

B. 21.

C. 23.

D. -2.

Q64. The prefix expression of the postfix expression AB+CD-* is.

A. (A+B)*(C-D).

B. (A*B)+(C*D).

C. A+*BCD-.

D. *+AB-CD.

Q65. Consider the postfix expression 4 5 6 a b 7 8 a c, where a, b, c are operators. Operator a has higher precedence over operators b and c. Operators b and c are right associative. Then, equivalent infix expression is.

A. 4 a 5 6  b 7 8 a c.

B. 4 a 5 c 6 b 7 a 8.

C. 4 b 5 a 6 c 7 a 8.

D. 4 a 5 b 6 c 7 a 8.

Answer= 4 b 5 a 6 c 7 a 8

Q66. To convert the postfix expression into the infix expression we use stack and scan the postfix expression from left to right..

A. TRUE.

B. FALSE.

C.  Nothing Can be said.

D.  None of the mentioned.

Q67. Which of the following is valid reverse polish expression?.

A. a op b.

B. op a b.

C. a b op.

D. both op a b and a b op.

Q68. The result of the postfix expression 5 3 * 9 + 6 / 8 4 / + is.

A. 8.

B. 6.

C. 10.

D. 9.

Q69. Which data structure can be used suitably to solve the Tower of Hanoi problem?.

A. Tree.

B. Heap.

C. Priority queue.

D. Stack.

Q70. What will be the resulting array after reversing arr[]={3,5,4,2}?.

A. 2,3,5,4.

B. 4,2,3,5.

C. 5,4,2,3.

D. 2,4,5,3.

Q71. How many swaps are required for reversing an array having n elements where n is an odd number?.

A. (n-1) / 2.

B. n/2.

C. (n/2) - 1.

D. (n+1)/2.

Q72. How many swaps are required for reversing an array having n elements where n is an even number?.

A. (n-1) / 2.

B. n/2.

C. (n/2) - 1.

D. (n+1)/2.

Q73. When array reversal and rotation is applied to the same array then the output produced will also be the same every time..

A. TRUE.

B. FALSE.

C.  Nothing can be said.

D.  None of the mentioned.

Q74. Which of the following is the predefined function for array reversal in C++ ?.

A. reverse().

B. arr_reverse().

C. array_reverse().

D. rev().

Q75. Which of the following is the predefined function for array reversal in javascript?.

A. reverse().

B. arr_reverse().

C. array_reverse().

D. rev().

Q76. Predefined function reverse() in C++ is available under which header file?.

A. math.

B. stdio.

C. stdlib.

D. algorithm.

Q77. What is the time complexity of balancing parentheses algorithm?.

A. O (N).

B. O (N log N).

C. O (M log N).

D. O (N2).

Q78. Which application of stack is used to ensure that the pair of parentheses is properly nested?.

A. Balancing symbols.

B. Reversing a stack.

C. Conversion of an infix to postfix expression.

D. Conversion of an infix to prefix expression.

Q79. In balancing parentheses algorithm, the string is read from?.

A. right to left.

B. left to right.

C. center to right.

D. center to left.

Q80. Which is the most appropriate data structure for applying balancing of symbols algorithm?.

A. stack.

B. queue.

C. tree.

D. graph.

Q81. Which of the following does the balancing symbols algorithm include?.

A. balancing double quotes.

B. balancing single quotes.

C. balancing operators and brackets.

D. balancing parentheses, brackets and braces.

Answer= balancing parentheses, brackets and braces

Q82. Which of the following statement is incorrect with respect to balancing symbols algorithm?.

A. {[()]}.

B. ([ )] .

C. {( )}.

D. { [ ] }.

Q83. What should be done when an opening parentheses is read in a balancing symbols algorithm?.

A. push it on to the stack.

B. throw an error.

C. ignore the parentheses.

D. pop the stack.

Answer= push it on to the stack

A. The stack is popped.

B. Ignore the parentheses.

C. An error is reported.

D. It is treated as an exception.

Q85. If the corresponding end bracket/braces/parentheses is encountered, which of the following is done?.

A. push it on to the stack.

B. pop the stack.

C. throw an error.

D. treated as an exception.

Q86. An error is reported when the stack is not empty at the end..

A. TRUE.

B. FALSE.

C.  Nothing can be said.

D.  None of the mentioned.

Q87. Is the given statement ((A+B) + [C-D]] valid with respect to balancing of symbols?.

A. TRUE.

B. FALSE.

C.  Nothing can be said.

D.  None of the mentioned.

Q88. How many passes does the balancing symbols algorithm makes through the input?.

A. one.

B. two.

C. three.

D. four.

Q89. Which of the following statement is invalid with respect to balancing symbols?.

A. [(A+B) + (C-D)] .

B. [{A+B}-{C-[D+E]}] .

C. ((A+B) + (C+D).

D. {(A+B) + [C+D]}.

Q90. What is a bit array?.

A. Data structure for representing arrays of records.

B. Data structure that compactly stores bits.

C. An array in which most of the elements have the same value.

D. None of the mentioned.

Answer= Data structure that compactly stores bits

Q91. Which of the following bitwise operations will you use to set a particular bit to 1?.

A. OR.

B. AND.

C. XOR.

D. NOR.