Drawing Trees Through MATHHELPBOARDS: Pre-Order, In-Order, Post-Order

  • Context: MHB 
  • Thread starter Thread starter evinda
  • Start date Start date
  • Tags Tags
    Drawing Trees
Click For Summary

Discussion Overview

The discussion revolves around tree traversal methods—specifically pre-order, in-order, and post-order traversals—using the term "MATHHELPBOARDS" as a reference. Participants explore the characteristics of these traversals in relation to binary trees and other tree structures.

Discussion Character

  • Exploratory
  • Debate/contested
  • Technical explanation

Main Points Raised

  • Some participants express uncertainty about whether their tree traversals are correct.
  • Others assert that multiple tree structures can yield valid pre-order traversals.
  • There is a discussion about whether the trees must be binary, with some suggesting that non-binary trees are also possible.
  • Participants question the choice of root nodes and their implications for traversal order, particularly regarding the letter 'M' as a potential root.
  • One participant notes that in-order traversal is not well-defined for non-binary trees, while others clarify that pre-order and post-order can apply to any tree structure.
  • There is a specific inquiry about the order of nodes in post-order traversal, with a focus on the leftmost nodes and their sequence.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the necessity of binary trees for certain traversals, and there are competing views regarding the appropriate root node for the tree. The discussion remains unresolved regarding the implications of these choices on traversal outcomes.

Contextual Notes

Some participants express confusion about the definitions and requirements for different types of tree traversals, particularly in relation to binary versus non-binary trees. There are also unresolved questions about specific traversal sequences and node placements.

evinda
Gold Member
MHB
Messages
3,741
Reaction score
0
Hello! (Wave)

I want to draw trees, that traverse "MATHHELPBOARDS" in:

  • pre-order
  • in-order
  • post-order

That's what I have tried:




Could you tell me if it is right or if I have done something wrong? (Thinking)
 

Attachments

  • pre.png
    pre.png
    5.2 KB · Views: 135
  • pre.png
    pre.png
    4.6 KB · Views: 128
  • pre.png
    pre.png
    4.7 KB · Views: 142
Technology news on Phys.org
evinda said:
Hello! (Wave)

I want to draw trees, that traverse "MATHHELPBOARDS" in:

  • pre-order
  • in-order
  • post-order

Hey! (Blush)

All of them are right! (Clapping)

Are they the only possibilities? (Wondering)
 
I like Serena said:
Hey! (Blush)

All of them are right! (Clapping)

(Party) (Happy)

I like Serena said:
Are they the only possibilities? (Wondering)

No, there are more possibilities. An other tree, that traverses "MATHHELPBOARDS" in pre-order is this:

View attachment 3585

Or am I wrong? (Thinking)
 

Attachments

  • preorder.png
    preorder.png
    3.8 KB · Views: 129
evinda said:
No, there are more possibilities. An other tree, that traverses "MATHHELPBOARDS" in pre-order is this:

Or am I wrong? (Thinking)

Nice! (Happy)

I see they are all binary trees.
Do they have to be binary trees? (Wondering)
 
I like Serena said:
Nice! (Happy)

I see they are all binary trees.
Do they have to be binary trees? (Wondering)

I think that it is possible that they are not binary trees.. Am I right? (Thinking)
 
evinda said:
I think that it is possible that they are not binary trees.. Am I right? (Thinking)

We could put the 'M' in the root, and ATHHELPBOARDS as children of the root.
This is pre-order.
Can we also do in-order? (Wondering)
 
I like Serena said:
We could put the 'M' in the root, and ATHHELPBOARDS as children of the root.
This is pre-order.
Can we also do in-order? (Wondering)

Is this a possible tree? (Thinking)

View attachment 3592
Or am I wrong? (Thinking)
 

Attachments

  • in.png
    in.png
    4.3 KB · Views: 127
evinda said:
Is this a possible tree? (Thinking)

I don't think so. (Worried)
Why would M be the first node in this tree? (Wondering)
 
I like Serena said:
I don't think so. (Worried)
Why would M be the first node in this tree? (Wondering)

(Worried) With which node should I start then? :confused:
 
  • #10
evinda said:
(Worried) With which node should I start then? :confused:

Well, I'm assuming that S is the root.
Or isn't it? (Thinking)

So if we do a pre-order traversal, S should be the first letter.
For a post-order traversal, L is the first letter.
And in in-order traversal is not properly defined for a tree that is not binary, but if it was, L would still be the first letter. (Nerd)

How can M be the first letter? (Wondering)
 
  • #11
I like Serena said:
Well, I'm assuming that S is the root.
Or isn't it? (Thinking)

So if we do a pre-order traversal, S should be the first letter.
For a post-order traversal, L is the first letter.
And in in-order traversal is not properly defined for a tree that is not binary, but if it was, L would still be the first letter. (Nerd)

How can M be the first letter? (Wondering)

So, can we just traverse a tree in post-order and in-order, if it is a binary tree?
But.. we can traverse all trees in pre-order?
Or have I understood it wrong? (Thinking)
 
  • #12
evinda said:
So, can we just traverse a tree in post-order and in-order, if it is a binary tree?
But.. we can traverse all trees in pre-order?
Or have I understood it wrong? (Thinking)

We can traverse any tree in both pre-order and post-order.
It's just that in-order requires us to be able to distinguish between left and right.
And we can only do that with a binary tree. (Wasntme)
 
  • #13
I like Serena said:
We can traverse any tree in both pre-order and post-order.
It's just that in-order requires us to be able to distinguish between left and right.
And we can only do that with a binary tree. (Wasntme)

At the post-order, we have this row: left, right, root, right? (Thinking)

So, when we have, for example, this tree:

View attachment 3604

where do we have to put t? :confused:
 

Attachments

  • how.png
    how.png
    2.8 KB · Views: 118
  • #14
evinda said:
At the post-order, we have this row: left, right, root, right? (Thinking)
So, when we have, for example, this tree:

where do we have to put t? :confused:

Post-order would not start wit the 'm', but with the leftmost unlabeled node.
That is, it repeated takes the leftmost branch starting from the root until it encounters a leaf. (Worried)

Once we get to the 'm', the next node is indeed the 'a', and after that its right sibling. (Mmm)
 

Similar threads

Replies
14
Views
3K
Replies
3
Views
2K
  • · Replies 65 ·
3
Replies
65
Views
10K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
9
Views
3K