0% found this document useful (0 votes)
8 views3 pages

Stack Applications Questions

The document contains multiple-choice questions focused on stack applications, covering topics such as recursion, expression notation, and tree traversal. Each question tests knowledge on specific concepts, such as the minimum moves in the Tower of Hanoi and the importance of parentheses in infix expressions. The questions are designed to assess understanding of stack-related operations and their implications in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Stack Applications Questions

The document contains multiple-choice questions focused on stack applications, covering topics such as recursion, expression notation, and tree traversal. Each question tests knowledge on specific concepts, such as the minimum moves in the Tower of Hanoi and the importance of parentheses in infix expressions. The questions are designed to assess understanding of stack-related operations and their implications in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Multiple-Choice Questions on Stack Applications

1. Recursion Implementation
Question: In recursion, why are parameters and return addresses stored on
the stack?
a) To optimize CPU register usage.
b) To enable backtracking after base case execution.
c) To prevent variable name conflicts.
d) To reduce memory fragmentation.

2. Expression Notation
Question: The postfix expression `A B + C ` corresponds to which infix
expression?
a) `(A + B) C`
b) `A + (B C)`
c) `A B + C`
d) `(A B) + C`

3. Tower of Hanoi Complexity


Question: In the Tower of Hanoi problem, what is the minimum number
of moves required to solve the puzzle with 64 disks?

4. Infix-to-Postfix Conversion
Question: When converting `(A + B) C` to postfix, which operator leaves
the stack last?
a) `+`
b) `(`
c) ``
d) `)`

5. Recursion vs. Iteration


Question: Why might recursion be avoided for large inputs despite
cleaner code?
a) Stack overflow risk from deep call stacks.
b) Increased register efficiency.
c) Better cache locality.
d) Lower space complexity.
6. Postfix Evaluation
Question: For postfix `3 4 5 +`, the stack state after processing `` is:
a) `[3, 20]`
b) `[12]`
c) `[12, 5]`
d) `[60]`

7. Base Conversion
Question: Converting decimal 10 to binary using a stack requires how
many pushes?
a) 2
b) 4 (for bits 1010)
c) 8
d) 10

8. Stack in Tree Traversal


Question: How does a stack assist in iterative tree traversal?
a) Stores node values for sorting.
b) Tracks pending nodes for depth-first exploration.
c) Holds parent pointers.
d) Balances the tree.

9. Prefix Expression
Question: The prefix expression `- A B C` evaluates to:
a) `(A B) - C`
b) `A (B - C)`
c) `(A B) - C`
d) `A - B C`

10. Recursive Factorial Defect


Question: The given factorial function fails for `number=0` because:

a) Initial `factorial=1` breaks for 0! = 1.


b) Missing base case for 0.
c) Pre-decrement error.
d) Uninitialized variable.
11. Stack Frame Purpose
Question: In recursion, the prologue step does NOT store:
a) Return address.
b) Parameters.
c) Result of final computation.
d) Local variables.

12. Illegal Hanoi Move


Question: Which violates Tower of Hanoi rules?
a) Moving top disk from source to auxiliary.
b) Placing disk 3 atop disk 1.
c) Moving one disk at a time.
d) Using all three towers.

13. Infix Conversion Step


Question: When converting `A + B C` to postfix, when is `+` pushed to
the stack?
a) Immediately after reading `A`.
b) After reading `B`.
c) After reading `` and popping higher-precedence operators.
d) After end of expression.

14. Postfix Calculator


Question: For `2 3 4 + `, the first stack pop operation retrieves:
a) `2`
b) `3`
c) `7` (result of `3+4`)
d) `4`

15. Expression Parentheses


Question: Why are parentheses critical in infix `(A + B) C`?
a) Override default precedence (`` > `+`).
b) Define variable scope.
c) Mark expression boundaries.
d) Enable lazy evaluation.
Answer: a)

You might also like