473,382 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

prefix to infix conversion

Hi every one,

can any help me in converting prefix to infix using Stack in c I know
the reverse

Dec 23 '06 #1
3 6439
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.
Dec 23 '06 #2
Thank you Richard you suggested recursive solution can it possible to
have iterative one for this.I tried a lot for iterative i m not getting
..

Richard Heathfield wrote:
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.
Dec 26 '06 #3
NageshB wrote:
>
Thank you Richard you suggested recursive solution can it possible to
have iterative one for this.I tried a lot for iterative i m not getting
Please do not top-post. Your article should follow (or be
intermixed with) the material you quote, after snipping anything
irrelevant to your reply. See the following links:

--
Some informative links:
<http://www.geocities.com/nnqweb/>
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/>
Dec 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
5
by: KidLogik | last post by:
Hello! I am converting an infix expression string into a postfix so that I will be able to evaluate it easier -> (5*(((9+8)*(4*6))+7)) == 598+46**7+* I believe the rule is "Replace all...
19
by: caramel | last post by:
i've been working on this program forever! now i'm stuck and going insane because i keep getting a syntax error msg and i just can't see what the compiler is signaling to! #include <stdio.h>...
11
by: Nhd | last post by:
Hi... I need a program to convert an infix arithmetic expression to postfix with the use of stacks... Can anyone tell me how do i go about implementing this? thanks
5
by: Thumbski | last post by:
Alright basically I just have one simple question. I can code perfectly fine and don't have any problems with the .cpp of the infix class but with my header I can't get anything to work really, any...
30
by: Xah Lee | last post by:
The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations Xah Lee, 2006-03-15 In LISP languages, they use a notation like “(+ 1 2)” to mean “1+2”....
0
by: coolguyjas07 | last post by:
plzzzzzz help me out to run my source code ......... i hav written dis code to convert infix expression to postfix but not getting desired output.... plzzz help me to get correct output.. d source...
1
by: aitia | last post by:
this the code. i used ECLIPSE to run this.. it has some codes smells that i can't seem to figure out.. can any one help? import java.io.*; import java.util.*; public class Postfix { private...
2
by: zeroeight | last post by:
Hi guys, I'm a newbie here, I just want to seek for help regarding my program. I want to implement an infix to postfix conversion only accepting numbers. Right now, I already debugged the errors...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.