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

In summary: 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)
  • #1
evinda
Gold Member
MHB
3,836
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: 83
  • pre.png
    pre.png
    4.6 KB · Views: 80
  • pre.png
    pre.png
    4.7 KB · Views: 89
Technology news on Phys.org
  • #2
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)
 
  • #3
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: 79
  • #4
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)
 
  • #5
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)
 
  • #6
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)
 
  • #7
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: 75
  • #8
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)
 
  • #9
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: 65
  • #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)
 

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

What is the purpose of "Drawing Trees Through MATHHELPBOARDS: Pre-Order, In-Order, Post-Order"?

The purpose of "Drawing Trees Through MATHHELPBOARDS: Pre-Order, In-Order, Post-Order" is to teach students how to represent and manipulate data in the form of trees using three different traversal methods: pre-order, in-order, and post-order. These methods are commonly used in computer science and mathematics to organize and analyze data in a structured manner.

What is the difference between pre-order, in-order, and post-order traversal?

Pre-order traversal involves visiting the root node first, followed by the left subtree, and then the right subtree. In-order traversal visits the left subtree first, then the root node, and finally the right subtree. Post-order traversal visits the left subtree, then the right subtree, and finally the root node.

How can "Drawing Trees Through MATHHELPBOARDS: Pre-Order, In-Order, Post-Order" benefit students?

By learning these three traversal methods, students can improve their problem-solving skills and logical thinking abilities. They will also gain a better understanding of data organization and manipulation, which are important concepts in computer science and mathematics.

Is prior knowledge in mathematics or computer science required to understand this topic?

No, prior knowledge in mathematics or computer science is not required. This topic is suitable for students of all levels, as it starts with the basics and gradually progresses to more advanced concepts. However, a basic understanding of arithmetic and algebra may be helpful.

Can "Drawing Trees Through MATHHELPBOARDS: Pre-Order, In-Order, Post-Order" be applied to real-world problems?

Yes, the skills learned in this topic can be applied to real-world problems that involve organizing and analyzing data in a structured manner. This can be useful in fields such as computer science, data analysis, and even everyday tasks like organizing information in a spreadsheet or creating a family tree.

Back
Top