Infix expression has balanced parenthesis or not, Data Structure & Algorithms

Q. By making use of stacks, write an algorithm to determine whether the infix expression has balanced parenthesis or not.                                                                                                               

Ans.

Algorithm parentheses is written below

This specific algorithm reads a source program and parses it to make sure all opening -closing parenthesis are systematically paired

1. loop (more data)

read (character)

if (character is not a closing parenthesis)

pushstack ( stack, character)

else

if (character is closing parenthesis)

popstack (stack, token)

while ( token is not an opening paranthesis)

popstack (stack, token)

endwhile end if

end if end loop

if (not emptystack (stack))

print (Error: opening parenthesis not matched)

end parseparens.

Posted Date: 7/13/2012 2:41:38 AM | Location : United States







Related Discussions:- Infix expression has balanced parenthesis or not, Assignment Help, Ask Question on Infix expression has balanced parenthesis or not, Get Answer, Expert's Help, Infix expression has balanced parenthesis or not Discussions

Write discussion on Infix expression has balanced parenthesis or not
Your posts are moderated
Related Questions

design algorithm and flow chart that computes the absolute difference of two values x and y


Elaborate the symbols of abstract data type length(a)-returns the number of characters in symbol a. capitalize(a)-returns the symbol generated from a by making its first cha

Warnock's Algorithm An interesting approach to the hidden-surface problem was presented by Warnock. His method does not try to decide exactly what is happening in the scene but

The controversy of RISC versus CISC never ends. Suppose that you represent an advocate for the RISC approach; write at least a one-page critic of the CISC approach showing its disa

Hear is given a set of input representing the nodes of a binary tree, write a non recursive algorithm that must be able to give the output in three traversal orders. Write down an

what algorithms can i use for the above title in my project desing and implmentation of road transport booking system

Explain about Franklin Algorithm We mentioned how the number of possible comparisons of polygons grows as the square of the number of polygons in the scene. Many of the hidden-

System defined data types:- These are data types that have been defined by the compiler of any program. The C language contains 4 basic data types:- Int, float,  char and doubl