Results 1 to 10 of 10
  1. #1
    sfe23's Avatar
    sfe23 is offline Member
    Join Date
    Feb 2009
    Posts
    42
    Rep Power
    0

    Default Postfix into prefix and vice versa

    How to convert postfix arithmetic expression into prefix arithmetic expression and vice versa?

    can someone tell me how to find the algorithm and the code plz?

  2. #2
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default All roads lead to Polish Notation

    I don't recall the details of postfix or prefit.
    When I think about it, I can't imagine the
    data structure changing at all. In both
    cases you will have a stack with values,
    and a stack with operations.

    The key is the algorithm that interprets the
    stack data.

    (I hope someone corrects me on this if I'm
    wrong.)

    Look up the algorithm for Polish Notaion
    in a data structure text. The postfix and
    prefix algorithms are probably at the
    beginning of that chapter.

  3. #3
    sfe23's Avatar
    sfe23 is offline Member
    Join Date
    Feb 2009
    Posts
    42
    Rep Power
    0

    Default

    Thanks for your answer.
    I already know what postfix and prefix are.
    I need to come up with an algorithm convering postfix to prefix and vice-versa!
    how can I do that?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    There are many posted on the web. I have found such in the past easily with a Google search. Most aren't a Java code conversion but it's not hard to convert from one code to another for this.

  5. #5
    sfe23's Avatar
    sfe23 is offline Member
    Join Date
    Feb 2009
    Posts
    42
    Rep Power
    0

    Default

    I have searched the web but could not find any!
    I must have looked at 100 pages already!
    when it comes to converting postfix to infix or vice-vera, they give the algorithm or the code using trees and not stack!
    I appreciate it if you give me a website if you already know of it.
    thanks

  6. #6
    sfe23's Avatar
    sfe23 is offline Member
    Join Date
    Feb 2009
    Posts
    42
    Rep Power
    0

    Default

    programmerassist.com/question/93 is one in Java but I do not understand it at all!!! :(

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    It's been a while since I looked, sorry. Best of luck though.

  8. #8
    sfe23's Avatar
    sfe23 is offline Member
    Join Date
    Feb 2009
    Posts
    42
    Rep Power
    0

    Default

    ahh.. too bad.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Wait, here's one I bookmarked:
    Postfix Notation Mini-Lecture

  10. #10
    sfe23's Avatar
    sfe23 is offline Member
    Join Date
    Feb 2009
    Posts
    42
    Rep Power
    0

    Default

    Fubarable, thanks for the link.
    But I already know the algorithm converting from infix to postfix or infix to prefix.
    My concern is postfix to prefix and prefix to postfix using stacks.
    :)

Similar Threads

  1. converting image to binary code n vice versa
    By nupurashi in forum Advanced Java
    Replies: 4
    Last Post: 04-01-2009, 07:27 PM
  2. Replies: 5
    Last Post: 10-04-2008, 11:13 AM
  3. Converting to ASCII and vice-versa
    By pheonix in forum New To Java
    Replies: 2
    Last Post: 09-09-2008, 04:43 AM
  4. Replies: 0
    Last Post: 04-07-2008, 07:44 AM
  5. Document conversion PDF to MS doc and vice versa
    By abintoms in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 12:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •