Thread: evalutaing a prefix expression

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    18

    evalutaing a prefix expression

    Is there an algorithm to evaluate a prefix expression. I googled and i could find a lot on evaluating a postfix expression using a stack. Thats cool, but i found almost no info on evaluating a prefix expression.

    For example,
    if the prefix expression is : +-/+abcd*fg,
    the infix should be evaluated as (a+b)/c-d+(f*g)

  2. #2

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    I know you Googled, but so did I, and here's what I got:
    evaluate prefix expression - Google Search

    The first result was a lengthy article from dreamincode.net explaining the process.
    The second result was a Wikipedia article with some pseudo code for prefix evaluation.
    The third was a MS Word doc from University of Bridgeport explaining the process and giving pseudo code.
    The list goes on...

    If you need specific help, make a decent effort, post your code in code tags and ask a specific question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. initializer expression list treated as compound expression
    By karthikeyanvisu in forum C Programming
    Replies: 7
    Last Post: 02-26-2011, 05:19 PM
  2. Replies: 2
    Last Post: 11-25-2009, 07:38 AM
  3. How to evaluate a postfix|prefix expression using stack?
    By Marrah_janine in forum C Programming
    Replies: 5
    Last Post: 08-04-2007, 04:12 AM
  4. which to prefix with std:: ??
    By wakish in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2005, 02:58 PM