In an office, at various times during the day the boss gives the secretary a letter to type, each time putting the letter on top of the pile in the secretary's inbox. secretary takes the top letter and types it. boss delivers in the order 1, 2, 3, 4, 5 which cannot be the order in which secretary types?
Answers
Answer:
Option B cannot be the order in which the secretary types.
Step-by-step explanation:
Step 1:
Simple stack concept. Get the possible combination of popping a stack order can be
Step 2:
1)push 1, pop 1, push 2, pop 2,push 3, pop 3,push 4, pop 4,push 5, pop 5 so, letter popping order 1, 2, 3, 4, 5 so we can conclude d is correct.
Step 3:
2)push 1,push 2,push 3, pop 3,pop 2,push 4,pop 4, pop 1,push 5,pop 5 so, popping order 3,2,4,1,5.so option c correct.
Step 4:
3)push 1, push 2, pop 2, push 3, push 4, pop 4, pop 3, push 5, pop 5, pop 5 so, popping order 2,4,3,5,1 so, option a is correct.
Step 5:
4) push 1, push 2, push 3, push 4, pop 4, push 5, pop 5.Now not possible to pop 2 without popping 3.
So this cannot be a popping order. Thus, we can conclude b is not correct.