6,945 views

4 Answers

Best answer
37 votes
37 votes
STACK scan the expression from left to right whenever a left paranthesis is encountered just PUSH it into stack and whenever a right paranthesis is encountered just POP it from stack. If at the end of expression we are left with an empty stack then it is a correctly parenthesized expression.
edited by
5 votes
5 votes

this might Help you

5 votes
5 votes
Example of Stack

7  -  (   (  x  *  (  (  x  +  y  )  / (  j  -  3   )  )  +  y   )  /  (  4  -  2.5  )  )
0 0  1  2 2 2  3 4 4  4  4 3 3 4 4 4 4  3  2 2  2  1 1  2 2  2   2  1 0

Eventually we get 0 in stack
Answer:

Related questions

27 votes
27 votes
3 answers
2
Kathleen asked Sep 18, 2014
5,595 views
The elements $32, 15, 20, 30, 12, 25, 16,$ are inserted one by one in the given order into a maxHeap. The resultant maxHeap is
19 votes
19 votes
3 answers
4
Kathleen asked Sep 18, 2014
6,388 views
Level order traversal of a rooted tree can be done by starting from the root and performingpreorder traversalin-order traversaldepth first searchbreadth first search