0

What is the sequence for inorder, preorder, postorder for

----------------------A---------------------------
---------------------/--\--------------------------
--------------------B---C-------------------------
-------------------/-\--/-\------------------------
------------------D-E-F-------------------------
----------------/-\-/-\---------------------------
----------------G-----H--------------------------

Is it correct for

Inorder:GDBHEAFC
Preorder:ABDGEHCF
Postorder:GDHEBFCA

if someone out there can help that will be awesome.

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Grn Xtrm
0

I highly recommend formatting your tree in a text editor set to a monospace font. I'm assuming this is the tree you wanted:

A
             /   \
           B       C
          / \     /
         D   E   F
        /     \
       G       H

Normally when people ask "is this right" questions, I reply with "test it and find out". The code to write a simple binary tree and test the traversals is very simple. However, I will say that you're on the right track. ;)

0

preorder = visit node, left, right
inorder = left, visit, right
postorder = left, right, visit

Repeat the process at each node.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.