NageshB said:
Hi every one,
can any help me in converting prefix to infix using Stack in c I know
the reverse
The belt-and-braces technique is easy enough:
prefix_to_infix(stream, stack)
if stack is not empty
pop a node off the stack
if this node represents an operator
write an opening parenthesis to stream
prefix_to_infix(stream, stack)
write operator to stream
prefix_to_infix(stream, stack)
write a closing parenthesis to stream
else
write value to stream
endif
endif
endfunc
Removing redundant parentheses is left as an exercise.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.