using stacks write an algorithm to determine


Using stacks, write an algorithm to determine whether the infix expression has balanced parenthesis or not

Algorithm parseparens

This algorithm reads a source program and parses it to make sure all opening -

closing parenthesis are 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.

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: using stacks write an algorithm to determine
Reference No:- TGS0282818

Expected delivery within 24 Hours