Connecting Tech Pros Worldwide Help | Site Map

pls help me convert the infix notation to postfix notaion

Newbie
 
Join Date: Aug 2008
Posts: 1
#1: Aug 30 '08
pls help me fo my assignment that will allow the user to input infinite equations in infix type. and will output in postfix.

thanks!
Ganon11's Avatar
Moderator
 
Join Date: Oct 2006
Location: New York, United States of America
Posts: 3,428
#2: Aug 30 '08

re: pls help me convert the infix notation to postfix notaion


You will need some sort of algorithm first, before you start coding at all. Any ideas?
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#3: Aug 30 '08

re: pls help me convert the infix notation to postfix notaion


Quote:

Originally Posted by jimmuel001

pls help me fo my assignment that will allow the user to input infinite equations in infix type. and will output in postfix.

thanks!

Have you considered Google? Searching for "infix to postfix" gives you loads of
example solutions in lots of languages including C and C++.

kind regards,

Jos
Member
 
Join Date: Apr 2008
Location: Illinois
Posts: 92
#4: Aug 31 '08

re: pls help me convert the infix notation to postfix notaion


1. Try giving us the Regular Expression Grammar in which you plan to do this.

2. After finding that out, then comes how to code that grammar into an algorithm (or pseudo-code of how that grammar should work).

3. Then from that algorithm/pseudo-code we can help you with coding it.

Start with #1, and we'll help you through the steps : )

Also, to note: Latex and Caml are two languages which excel at this type of thing. Worry about your assignment, but it's an interesting note to think about.
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#5: Aug 31 '08

re: pls help me convert the infix notation to postfix notaion


Quote:

Originally Posted by TamusJRoyce

1. Try giving us the Regular Expression Grammar in which you plan to do this.

Note that a regular expression can't describe the syntax of ordinary infix expressions.
See the pumping lemma for a nice proof.

kind regards,

Jos
Member
 
Join Date: Apr 2008
Location: Illinois
Posts: 92
#6: Aug 31 '08

re: pls help me convert the infix notation to postfix notaion


Ah. The infix type got me. Keep on thinking it's an infinate language, which doesn't make sence.

Thank JosAH
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#7: Aug 31 '08

re: pls help me convert the infix notation to postfix notaion


Quote:

Originally Posted by TamusJRoyce

Ah. The infix type got me. Keep on thinking it's an infinate language, which doesn't make sence.

Thank JosAH

Both regular languages as well as context free languages can be infinite languages
but, as the pumping lemma clearly shows and as the saying goes: regular languages
can't count. You need to be able to count because of those parentheses that
make up nested expressions. In normal words: you can't come up with a
regular expression that matches a string of well balanced parentheses.

kind regards,

Jos
Reply