Consider the 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 3 tokens:

*, (, with * at the bottom, and at the top.

Now, suppose that you read and process the 11th token of the input. List the content of the stack for the case where the 11th token is:

a. A number:
b. A (:
c. A ):
d. A minus sign:
e. A division sign:

Respuesta :

Answer:

a. * ( +

b. * ( + (

c. *

d. * -

e. * ( + /

Explanation:

A stack is a data structure that holds data where the last data in the structure is retrieved before the first. The stack structure above can hold the characters *, ( and + of character stored in the stack. The content of the stack that matches the three characters and their 11th token is listed above.

ACCESS MORE