Stacks Applications Flashcards

1
Q

Infix to Postfix Algo

A

Create an empty stack called opstack for keeping operators. Create an empty list for output.
Convert the input infix string to a list by using the string method split.
Scan the token list from left to right.
If the token is an operand, append it to the end of the output list.
If the token is a left parenthesis, push it on the opstack.
If the token is a right parenthesis, pop the opstack until the corresponding left parenthesis is removed. Append each operator to the end of the output list.
If the token is an operator, *, /, +, or -, push it on the opstack. However, first remove any operators already on the opstack that have higher or equal precedence and append them to the output list.
When the input expression has been completely processed, check the opstack. Any operators still on the stack can be removed and appended to the end of the output list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Evaluating a postfix

A

We read the tokens in one at a time.
If it is an integer, push it on the stack
If it is a binary operator, pop the top two elements from the stack, apply the operator, and push the result back on the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Parenthesis checker

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Recursion

A

aa

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Interrupt handling

A

aa

How well did you know this?
1
Not at all
2
3
4
5
Perfectly