Semester : II
Scan the expression from left to right.
·
The first entry to be
scanned is ‘{’, which is a left parenthesis.
·
Push it into the
stack.
·
The next entry to be
scanned is ‘(’, which is a left parenthesis.
·
Push it into the
stack.
·
The next entry is
‘a’, which is an operand. Therefore, it is discarded.
·
The next entry is
‘+’, which is an operator. Therefore, it is discarded.
·
The next entry is
‘b’, which is an operand. Therefore, it is discarded.
·
The next entry to be
scanned is ‘)’, which is a right parenthesis
·
POP the topmost entry
from the stack.
·
Match the two
brackets.
·
The next entry to be
scanned is ‘×’, which is an operator. Therefore, it is discarded.
·
The next entry to be scanned
is ‘(’, which is a left parenthesis
·
Push it into the
stack
·
The next entry to be
scanned is ‘c’, which is an operand. Therefore it is discarded
·
The next entry to be
scanned is ‘+’, which is an operator. Therefore it is discarded
·
The next entry to be
scanned is ‘d’, which is an operand. Therefore it is discarded
·
The next entry to be
scanned is ‘)’, which is a right parenthesis.
·
POP the topmost
element from the stack.
·
Match the two
brackets.
·
The next entry to be
scanned is ‘+’, which is an operator. Therefore, it is discarded.
·
The next entry to be
scanned is ‘(’, which is a left parenthesis.
·
Push it into the
stack.
·
The next entry to be
scanned is ‘c’, which is an operand. Therefore, it is discarded.
·
The next entry to be
scanned is ‘×’, which is an operator. Therefore, it is discarded.
·
The next entry to be scanned
is ‘d’, which is an operand. Therefore, it is discarded.
·
The next entry to be
scanned is ‘)’, which is a right parenthesis.
·
POP the topmost
element from the stack.
·
Match the two
brackets.
·
The next entry to be
scanned is ‘]’, which is a right parenthesis.
·
POP the topmost
element from the stack.
·
Match the two
brackets
Nice Blog. Thanks for sharing with us. Such amazing information.
ReplyDeletebest BBA College in Dehradun