Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Explain what modifications would be needed to make the parenthesis matching algo

ID: 3685496 • Letter: E

Question

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<int> s;

   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<int> s;

   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:

Explanation / Answer

data[0]=1
data[1]=2

hear_prt=data[0]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote