Question: Explain what modifications would be needed to make the parenthesis matching algorithm check expressions with different kinds of parentheses such as (), [] and {}'s.
Explain what modifications would be needed to make the parenthesis matching algorithm check expressions with different kinds of parentheses such as (), [] and {}'s.
I am going to execute this code with THREE pushes and ONE pop:
stack
s.push(1);
s.push(2);
s.push(3);
s.pop( );
Suppose that s is represented by a partially filled array. Draw the state of the private member variables of s after the above code:
_______ __________________________________
used| | data| | | | | |
|_______| |______|______|______|______|______|
[0] [1] [2] [3] [4]
I am going to execute this code with THREE pushes and ONE pop:
stack
s.push(1);
s.push(2);
s.push(3);
cout << s.pop( );
Suppose that s is represented by a linked list. Draw the state of the private member variables of s after the above code:
_______
head_ptr| |
|_______|
Consider the usual algorithm to convert an infix expression to a postfix expression. Suppose that you have read 10 input characters during a conversion and that the stack now contains these symbols:
| |
| + |
| ( |
bottom |___*___|
Now, suppose that you read and process the 11th symbol of the input. Draw the stack for the case where the 11th symbol is:
A. A number:
B. A left parenthesis:
C. A right parenthesis:
D. A minus sign:
E. A division sign:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
