hi guys
so i want help with the concept or idea behind it
using stacks, pop,push,retrieve
can you guys, tell me the concept behind it?
or just the basic idea of it
and after i come to understand how it must work, ill post some codes
please?
thanks
3 Replies  1709 Views  Last Post: 12 February 2010  04:37 PM
Replies To: infix to postfix
#2
Re: infix to postfix
Posted 12 February 2010  09:55 AM
This has probably been posted in the wrong forum!
Infix notation is what we normally use to write down mathematical formula such as 2 + 5. Postfix notation would be 2 5 +. Seen from a computer perspective, infix notation is not very easy to handle, whereas 2 5 + can be accommodated using a stack.
1. Push 2
2. Push 5
3. + (pop 5 pop 2 and add together)
Some programming languages expect their input in postfix notation. FORTH being a prime example.
Hope that helps.
Infix notation is what we normally use to write down mathematical formula such as 2 + 5. Postfix notation would be 2 5 +. Seen from a computer perspective, infix notation is not very easy to handle, whereas 2 5 + can be accommodated using a stack.
1. Push 2
2. Push 5
3. + (pop 5 pop 2 and add together)
Some programming languages expect their input in postfix notation. FORTH being a prime example.
Hope that helps.
This post has been edited by Martyn.Rae: 12 February 2010  09:56 AM
#3
Re: infix to postfix
Posted 12 February 2010  04:20 PM
thanks martyn!
im coding this in C++ so i thought this is the right subforum
what i wanted is the idea of a program that
1. reads an input of string (infix)
2. converts that string to postfix (without operating on it)
im coding this in C++ so i thought this is the right subforum
what i wanted is the idea of a program that
1. reads an input of string (infix)
2. converts that string to postfix (without operating on it)
#4
Re: infix to postfix
Posted 12 February 2010  04:37 PM
Reading the input shouldn't pose too much of a problem  the C++ string and stringstream libraries should be able to help you split a string into tokens (operators/operands)
Take a look at Dijkstra's shunting yard algorithm for the conversion
http://en.wikipedia....yard_algorithm
It might help to set up a mapping between operators and their precedence  remember that parenthesis are not part of postfix syntax, so they're a special case.
as for stacks, the C++ <stack> library will do everything you need  save you writing your own.
Take a look at Dijkstra's shunting yard algorithm for the conversion
http://en.wikipedia....yard_algorithm
It might help to set up a mapping between operators and their precedence  remember that parenthesis are not part of postfix syntax, so they're a special case.
as for stacks, the C++ <stack> library will do everything you need  save you writing your own.
This post has been edited by Bench: 12 February 2010  04:40 PM
Page 1 of 1
