Thread: Infix to Prefix

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    66

    Infix to Prefix

    Can anyone help me to convert an infix expression to a prefix expression?
    It should be using stacks, not binary trees.

    I just need the algorithm and I'll code it myself.
    I'll be glad if someone can tell me the algorithm since it's nowhere to be found.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Have you already searched the forum? It was discussed several times during last month...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Basic principle: infix consists of "term oper term", and you can resolve that by reading the term, oper and term, then stacking the term, term, oper or something like that.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Expression: Convert infix notation to postfix notation.
    By Nutshell in forum C Programming
    Replies: 7
    Last Post: 02-27-2010, 07:44 AM
  2. Infix to prefix conversion
    By bbanelli in forum C Programming
    Replies: 1
    Last Post: 11-19-2007, 02:17 PM
  3. infix to prefix.....damn my eyes are fried
    By misplaced in forum C++ Programming
    Replies: 10
    Last Post: 10-04-2004, 01:36 AM
  4. Infix to Postfix
    By dat in forum C Programming
    Replies: 6
    Last Post: 06-16-2003, 08:46 AM
  5. Inserting infix into a binary tree
    By Nakeerb in forum C++ Programming
    Replies: 20
    Last Post: 01-20-2003, 05:03 PM