Stacks

Question 1

Which of the following permutations can be obtained in the output (in the same order) using a stack assuming that the input is the sequence 1, 2, 3, 4, 5 in that order?

A
3, 4, 5, 1, 2
B
3, 4, 5, 2, 1
C
1, 5, 2, 3, 4
D
5, 4, 3, 1, 2
Question 1 Explanation: 
Push 1 Push 2 Push 3 Pop 3 Push 4 Pop 4 Push 5 Pop 5 Pop 2 Pop 1.
→ Remaining options are not possible.
Question 2

Which of the following is essential for converting an infix expression to the postfix from efficiently?

A
An operator stack
B
An operand stack
C
An operand stack and an operator stack
D
A parse tree
Question 2 Explanation: 
An operator stack ⇒ Infix to (Postfix or Prefix)
An operand stack ⇒ Postfix to Prefix
Operator & operand stack ⇒ We don't use two stacks
Parse tree ⇒ No use
There are 2 questions to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access