Question

Figure 1 Figure 1 For the tree in figure 1: • What is the output of preorder traversal? What is the output of inorder travers

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Preorder traversal is Root-Left-Right.
Algorithm for preorder is:

  1. Print the root node
  2. Visit the left child
  3. Visit the right child

So, the Preorder traversal is A-B-D-G-H-C-E-F-I-J

Inorder traversal is Left-Root-Right.
Algorithm for inorder is:

  1. Visit the left child
  2. Print the root node
  3. Visit the right child

So, the Inorder traversal is G-D-H-B-A-E-C-I-F-J

Postorder traversal is Left-Right-Root.
Algorithm for postorder is:

  1. Visit the left child
  2. Visit the right child
  3. Print the root node

So, the Postorder traversal is G-H-D-B-E-I-J-F-C-A

Add a comment
Know the answer?
Add Answer to:
Figure 1 Figure 1 For the tree in figure 1: • What is the output of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT