What is the maximum number of parenthesis that will appear on the stack at any one time for parenthesis expression given by ( ( ) ( ( ) ) ( ( ) ) )
3
Push on every "(" and pop on every ")", tracking the stack size.
Sizes after each symbol: 1, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 0.
The largest value reached is 3, inside the nested groups.
Check: the stack ends at 0, so the expression is balanced and the count is consistent.
Hence, 3.
How many PUSH and POP operations will be needed to evaluate the following expression by reverse polish notation in a stack machine \((A * B) + (C * D/E)\) ?
Single array a[0: MAXSIZE - 1] is used to implement two stacks. The two stacks grow from apposite ends of the array. Variables top 1 and top 2 (top1 < top2) point to the location of the topmost element in each of the stacks if the space is to be used efficiently, The condition for "stack full" is____________.
| (1) PUSH | (a) STACK |
| (2) FIFO | (b) Stack insertion |
| (3) POP | (c) QUEUE |
| (4) LIFO | (d) Stack deletion |