Given finite alphabet S = {A, B, C} and stack S of size 100. There are only three stack operations we can perform as mentioned below. Stack is initially empty and we do not perform pop ( ) on empty stack. Assume that only emit ( ) can print output and stack may or may not be empty finally. The minimum number of stack operations to get “A B C A C B A” as output are ______.
I am getting 15 but it is given 14. Please help.
Keyword:
Stack may or may not be empty finally
Don`t pop $A$ after emitting.
$1) $Push A
Emit A $:A$
Push B Emit B $:AB$
Push C Emit C $:ABC$
Push A Emit A $:ABCA$ Pop A Emit C $ABCAC$ Pop C Emit B $ABCACB$ Pop B $14)$ Emit A $ABCACBA$
MiNiPanda
By set here we mean domain of choice (like in alphabet in TOC). So we can have multiple instances of it.
All these PYQ blogs and standard videos blogs...