Theory-of-Computation
March 7, 2024Database-Management-System
March 8, 2024Data-Structures
Question 9
|
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?
3, 4, 5, 1, 2
|
|
3, 4, 5, 2, 1
|
|
1, 5, 2, 3, 4
|
|
5, 4, 3, 1, 2
|
Question 9 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.
→ Remaining options are not possible.
Correct Answer: B
Question 9 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.
→ Remaining options are not possible.
Subscribe
Login
0 Comments