Stacks & Queues

Answer & solution
Official answer: B, C, D
Step through it (4 options)
Approach: Give legal operation witnesses for possible orders and a storage lower bound for the impossible order.
1. Derivation. Write T for PushToS2, R for PushToS1, and O for GenerateOutput. Starting with S1 bottom-to-top100, 200, 300, 400 and empty S2: B is realized by T, T, O, R, O, R, O, O; C by O, T, O, O, R, O; D by T, O, O, R, O, O. These produce the stated sequences without exceeding S2 capacity 2. A cannot start with 100: reaching it before any output requires all three higher elements outside S1, but S2 holds only two. Thus B, C, D.
2. Explanation and checks. For B, the first two T operations park 400 then 300 in S2, exposing 200. Output 200, restore and output 300, restore and output 400, then output 100. For C, output 400 first and park only 300; this exposes both 200 and 100 before restoring 300. For D, park only 400 and output 300,200 before restoring it. No hidden extra buffer is available, which is why starting with 100 is impossible.