data structures (postfix/prefix)

This is a discussion on data structures (postfix/prefix) within the C Programming forums, part of the General Programming Boards category; Hi... I'm having a few problems with the book that I have regarding prefix and postfix portion of data structures. ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    17

    Question data structures (postfix/prefix)

    Hi...

    I'm having a few problems with the book that I
    have regarding prefix and postfix portion of
    data structures. I was wondering if anyone knew
    of a web site that might have a few examples that
    I could learn from.


    Maybe someone can tell me if I'm right or wrong:

    prob: Translate each of the following expressions from prefix to postfix:


    a) / + x y ! n (prefix)


    x y + / n ! (my answer in postfix)



    b) / + ! x y n (prefix)


    x y + / n ! (my answer in postfix)

    These are my results, I'm just looking to see if I am doing this right.
    Thanks,

    -Rick

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    I was wondering if anyone knew
    of a web site that might have a few examples that
    I could learn from.
    You could try here.
    zen

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    I like to think of it this way...

    / + x y ! n

    This is a postfix expression. We can treat each of the operators as a function really....
    /(a,b) returns a/b
    +(a,b) returns a + b
    !(a) returns !n
    ...
    /(+xy, !n)
    /(+(x,y),!(n))
    And to change it to postfix, we just have to move the operators to the other side of their parenthesis...
    (a,b)/ returns a/b
    (a, b)+ returns a + b
    (a)! returns !a
    ...
    /(+(x, y), !(n))
    becomes...
    ((x, y)+, (n)!)/
    x y + n ! /

    The hardest part is just realising which variables go to which operators...
    / + ! x y n
    / (+ (!(x), y), n)
    (((x)!, y)+, n)/
    x ! y + n /
    Callou collei we'll code the way
    Of prime numbers and pings!

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    11

    try this

    hi there,
    in terms of tree notations,
    postfix == left,right,root
    prefix == root,left,right
    infix == left,root,right

    first create the tree of infix form and then go for prefix and postfix notations...........
    Feedback is the breakfast of champions...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's a good generalized data structures book?
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 11-16-2006, 01:01 PM
  2. i need advice about data structures
    By sawer in forum C Programming
    Replies: 2
    Last Post: 04-22-2006, 04:40 AM
  3. Need some help regarding data structures
    By Afrinux in forum C Programming
    Replies: 15
    Last Post: 01-28-2006, 05:19 AM
  4. array of structures, data from file
    By nomi in forum C Programming
    Replies: 5
    Last Post: 01-11-2004, 01:42 PM
  5. Array Data Structures
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 03-27-2002, 06:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21