Results 1 to 7 of 7
  1. #1
    sim18 is offline Member
    Join Date
    Oct 2011
    Posts
    30
    Rep Power
    0

    Default Could somebody check my binary tree?

    could somebody please tell me what (A*B) / (C^D^E) is in POST ORDER.

    I drew the tree and went back over it in post order

    Java Code:
            /
       *      ^
     A  B   C   ^
                D  E
    From this I get :

    AB*C/D^E^, is this correct?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: Could somebody check my binary tree?

    First off, define exactly what you mean by post order.

    I might point out that AB*C/D^E^ isn't a valid expression.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default Re: Could somebody check my binary tree?

    Tree traversal - Wikipedia, the free encyclopedia

    To traverse a non-empty binary tree in postorder, perform the following operations recursively at each node[1]:
    Traverse the left subtree.
    Traverse the right subtree.
    Visit the root.

    @Kevin: I think the "right" postorder traversation will generate a non "valid expression" too....
    Last edited by eRaaaa; 11-28-2012 at 08:18 PM.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: Could somebody check my binary tree?

    Quote Originally Posted by eRaaaa View Post
    @Kevin: I think the "right" postorder traversation will generate a non "valid expression" too....
    Good point!
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,786
    Blog Entries
    7
    Rep Power
    21

    Default Re: Could somebody check my binary tree?

    The correct postfix expression (according to your tree) is: AB*CDE^^/

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,786
    Blog Entries
    7
    Rep Power
    21

    Default Re: Could somebody check my binary tree?

    Quote Originally Posted by KevinWorkman View Post
    I might point out that AB*C/D^E^ isn't a valid expression.
    Yes it is: it has five operands and four binary operators and the evaluation stack is never empty in between ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    sim18 is offline Member
    Join Date
    Oct 2011
    Posts
    30
    Rep Power
    0

    Default Re: Could somebody check my binary tree?

    Thank you very much

Similar Threads

  1. Binary tree
    By harmy in forum New To Java
    Replies: 1
    Last Post: 02-03-2012, 09:46 AM
  2. Binary Tree Help - Find the largest sub-tree
    By joshhazel in forum New To Java
    Replies: 2
    Last Post: 01-30-2012, 03:08 AM
  3. binary tree
    By ryamz in forum New To Java
    Replies: 2
    Last Post: 08-12-2010, 03:45 AM
  4. Replies: 0
    Last Post: 04-04-2010, 08:40 AM
  5. Binary Tree
    By MuslimCoder in forum New To Java
    Replies: 8
    Last Post: 11-19-2009, 06:57 PM

Posting Permissions

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