Skip to main content
Tweeted twitter.com/#!/StackCompSci/status/412171456463003648
edited body
Source Link

Consider this tree:

Simple binary tree

If I traverse it using post-order, I'd start at B (as it is the leftmost leefleaf) and that's where my misunderstanding begins. I know B is the first and A will be the last node in post order, as the rule is left-right-root. One of my university professors said the correct answer for the post-order traversal of a tree similar to the one above would be B, C, D, E, A, but in my understanding, it should be B, D, E, C, A.

Am I getting it wrong? Shouldn't I evaluate (C,D),(C,E) as a subtree and then go back to the parent tree?

Consider this tree:

Simple binary tree

If I traverse it using post-order, I'd start at B (as it is the leftmost leef) and that's where my misunderstanding begins. I know B is the first and A will be the last node in post order, as the rule is left-right-root. One of my university professors said the correct answer for the post-order traversal of a tree similar to the one above would be B, C, D, E, A, but in my understanding, it should be B, D, E, C, A.

Am I getting it wrong? Shouldn't I evaluate (C,D),(C,E) as a subtree and then go back to the parent tree?

Consider this tree:

Simple binary tree

If I traverse it using post-order, I'd start at B (as it is the leftmost leaf) and that's where my misunderstanding begins. I know B is the first and A will be the last node in post order, as the rule is left-right-root. One of my university professors said the correct answer for the post-order traversal of a tree similar to the one above would be B, C, D, E, A, but in my understanding, it should be B, D, E, C, A.

Am I getting it wrong? Shouldn't I evaluate (C,D),(C,E) as a subtree and then go back to the parent tree?

Source Link

Doesn't post-order traversal require subtrees to be evaluated separately?

Consider this tree:

Simple binary tree

If I traverse it using post-order, I'd start at B (as it is the leftmost leef) and that's where my misunderstanding begins. I know B is the first and A will be the last node in post order, as the rule is left-right-root. One of my university professors said the correct answer for the post-order traversal of a tree similar to the one above would be B, C, D, E, A, but in my understanding, it should be B, D, E, C, A.

Am I getting it wrong? Shouldn't I evaluate (C,D),(C,E) as a subtree and then go back to the parent tree?