These Application Of Stacks MCQs will give you a complete explanation of how to do decimal to binary using stacks, towers of hanoi, expression evaluation of infix, prefix and postfix, conversions like infix to postfix, postfix to infix, prefix to infix and infix to prefix conversions, reversing the word using stack and balanced parenthesis. We have the best collection of the Application Of Stacks MCQs and answer with FREE PDF. These Application Of Stacks MCQs will help you to prepare for any competitive exams like: BCA, MCA, GATE, GRE, IES, PSC, UGC NET, DOEACC Exams at all levels – you just have to practice regularly.
Application Of Stacks MCQs
1. 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
Answer: Balancing symbols
2. 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
Answer: left to right
3. Which is the most appropriate data structure for applying balancing of symbols algorithm?
a) stack
b) queue
c) tree
d) graph
Answer: stack
4. 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
5. Which of the following statement is incorrect with respect to balancing symbols algorithm?
a) {[()]}
b) ([ )]
c) {( )}
d) { [ ] }
Answer: ([ )]
6. 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
7. When the corresponding end bracket/braces/parentheses is not found, what happens?
a) The stack is popped
b) Ignore the parentheses
c) An error is reported
d) It is treated as an exception
Answer: An error is reported
100+ Balanced Parenthesis Question and Answer with FREE PDF
8. Which is the predefined method available in Java to convert decimal to binary numbers?
a) toBinaryInteger(int)
b) toBinaryValue(int)
c) toBinaryNumber(int)
d) toBinaryString(int)
Answer: toBinaryString(int)
9. What is the time complexity for converting decimal to binary numbers?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
Answer: O(logn)
Decimal to Binary Using Stacks Question with FREE PDF
10. 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
Answer: abc*+de-+
11. Reverse Polish Notation is the reverse of a Polish Notation.
a) True
b) False
Answer: False
12. 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)
Answer: O (N)
13. In Postfix expressions, the operators come after the operands.
a) True
b) False
Answer: True
14. Which of these operators have the highest order of precedence?
a) ‘(‘ and ‘)’
b) ‘*’ and ‘/’
c) ‘~’ and ‘^’
d) ‘+’ and ‘-‘
Answer: ‘~’ and ‘^’
15. 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
Answer: line at ticket counter
16. 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
17. 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
18. 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
Answer: 7
Evaluation of a Postfix Expression Question with FREE PDF
19. 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
Answer: right to left
20. The associativity of an exponentiation operator ^ is right side.
a) True
b) False
Answer: True
21. How many types of input characters are accepted by this algorithm?
a) one
b) two
c) three
d) four
Answer: three
22. 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
Answer: precedence and associativity
23. Find the output of the following prefix expression.
*+2-2 1/-4 2+-5 3 1
a) 2
b) 12
c) 10
d) 4
Answer: 2
24. An error is thrown if the character ‘\n’ is pushed in to the character stack.
a) true
b) false
Answer: false
25. Using the evaluation of prefix algorithm, evaluate +-9 2 7.
a) 10
b) 4
c) 17
d) 14
Answer: 14
26. 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
Answer: a=1, b=2, c=5, d=4
Evaluation of a Prefix Expression Question with FREE PDF
27. 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
28. 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
Answer: 5
29. Evaluation of infix expression is done based on precedence of operators.
a) True
b) False
Answer: True
30. Of the following choices, which operator has the lowest precedence?
a) ^
b) +
c) /
d) #
Answer: #
31. The system throws an error if parentheses are encountered in an infix expression evaluation algorithm.
a) True
b) False
Answer: False
32. 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
Answer: 4
33. 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
Answer: 10
50+ Evaluation of an Infix Expression (Not Parenthesized) MCQs with FREE PDF
34. Which of the following is an infix expression?
a) (a+b)*(c+d)
b) ab+c*
c) +ab
d) abc+*
Answer: (a+b)*(c+d)
35. What is the time complexity of an infix to postfix conversion algorithm?
a) O(N log N)
b) O(N)
c) O(N2)
d) O(M log N)
Answer: O(N)
36.What is the postfix expression for the corresponding infix expression?
a+b*c+(d*e)
a) abc*+de*+
b) abc+*de*+
c) a+bc*de+*
d) abc*+(de)*+
Answer: abc*+de*+
37. From the given Expression tree, identify the correct postfix expression from the list of options.
a) ab*cd*+
b) ab*cd-+
c) abcd-*+
d) ab*+cd-
Answer: ab*cd-+
38. 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
Answer: left to right
50+ Infix to Postfix Conversion MCQs with FREE PDF
39. 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
Answer: +A*BC
40. 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
Answer: **AB+CD
41. 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
Answer: +A*B^CD
42. Out of the following operators (^, *, +, &, $), the one having highest priority is _________
a) +
b) $
c) ^
d) &
Answer: ^
43. Out of the following operators (|, *, +, &, $), the one having lowest priority is ________
a) +
b) $
c) |
d) &
Answer: |
44. 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
Answer: ^^^ABCD
45. What would be the Prefix notation for the given equation?
a+b-c/d&e|f
a) |&-+ab/cdef
b) &|-+ab/cdef
c) |&-ab+/cdef
d) |&-+/abcdef
Answer: |&-+ab/cdef
46. 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
Answer: -+a*/bc^def
50+ Infix to Prefix Conversion MCQs with FREE PDF
47. What is the value of the postfix expression 2 3 + 4 5 6 – – *
a) 19
b) 21
c) -4
d) 25
Answer: 25
48. The prefix expression of the postfix expression AB+CD-* is __________
a) (A+B)*(C-D)
b) +AB*-CD
c) A+*BCD-
d) *+AB-CD
Answer: *+AB-CD
49. 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
50. 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
Answer: True
51. 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
Answer: a b op
52. The result of the postfix expression 5 3 * 9 + 6 / 8 4 / + is _____________
a) 8
b) 6
c) 10
d) 9
Answer: 6
50+ Postfix to Infix Conversion MCQs with FREE PDF
53. What would be the solution to the given prefix notation?
+ 9 * 3 / 8 4
a) 14
b) 15
c) 18
d) 12
Answer: 15
54. What would be the solution to the given prefix notation?
– + 1 2 * 3 / 6 2
a) 6
b) -6
c) 3
d) -3
Answer: -6
55. What would be the solution to the given prefix notation?
– * 1 5 / * / 6 3 6 2
a) 1
b) 0
c) -1
d) -2
Answer: -1
56. 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
Answer: 12
57. 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
50+ Prefix to Infix Conversion MCQs with FREE PDF
58. What is the time complexity of reversing a word using stack algorithm?
a) O (N log N)
b) O (N2)
c) O (N)
d) O (M log N)
Answer: O (N)
59. What will be the word obtained if the word “abbcabb” is reversed using a stack?
a) bbabbca
b) abbcabb
c) bbacbba
d) bbacabb
Answer: bbacbba
60. How many stacks are required for reversing a word algorithm?
a) one
b) two
c) three
d) four
Answer: one
50+ Reverse a Word using Stack MCQs with FREE PDF
61. The optimal data structure used to solve Tower of Hanoi is _________
a) Tree
b) Heap
c) Priority queue
d) Stack
Answer: Stack
62. Which among the following is not a palindrome?
a) Madam
b) Dad
c) Malayalam
d) Maadam
Answer: Maadam
63. Which data structure can be used to test a palindrome?
a) Tree
b) Heap
c) Stack
d) Priority queue
Answer: Stack
50+ Towers of Hanoi MCQs with FREE PDF
Application Of Stacks MCQs PDF Download
1000+ Data Structure MCQs
Categories: Application of Stacks