Let S1 and S2 be two stacks. S1 has capacity of 4 elements. S2 has capacity of 2 elements. S1 already has 4 elements: 100, 200, 300. and 400. whereas S2 is empty, as shown below.
400 (Top) | ||
300 | ||
200 | ||
100 |
Stack S1 Stack S2
Only the following three operations are available:
PushToS2: Pop the top element from S1 and push it on S2.
PushToS1: Pop the top element from S2 and push it on S1.
Generate Output: Pop the top element from S1 and output it to the user.
Note that the pop operation is not allowed on an empty stack and the push operation is not allowed on a full stack.
Which of the following output sequences can be generated by using the above operations?
Sign in to see the solution
Log in to view the explanation, track your attempts, and keep your progress.
Sign in to UnlockBrowse Practice Questions by Chapters / Topics in Browse Practice Questions by Chapters / Topics in GATE Computer Science
Total Questions
Attempted
% Attempted
Correct
% Correct
| Topic | Questions | Attempted | Correct | |
|---|---|---|---|---|
| C Programming and Data Structures | 142 | 0 | 0 | |
| Algorithms | 113 | 0 | 0 | |
| DBMS | 13 | 0 | 0 | |
| Operating Systems (OS) | 0 | 0 | 0 | |
| Computer Networks | 22 | 0 | 0 | |
| CDS | 10 | 0 | 0 | |
| C Programming & Data Structure | 22 | 0 | 0 | |
| 20 | 0 | 0 | 0 |