0% found this document useful (0 votes)
111 views

Binary - Tree Traversal Exercises

Uploaded by

medaziz864
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

Binary - Tree Traversal Exercises

Uploaded by

medaziz864
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Tree Traversal Exercises

1. Level Traversal: List the nodes in Breadth First Search or BFS.


2. Preorder Traversal: List the nodes in preorder.

3. Inorder Traversal: List the nodes in inorder.


4. Postorder Traversal: List the nodes in postorder.

1 1

2 3 2 3

4 5
6 7 4 5 6

7 8

1 2

2 3 3 4

4 5 5 6

6 7 8 7 8

1
• Inorder Traversal: 2, 6, 4, 1,
1 3, 7, 5, 8

• Postorder Traversal: 6, 4, 2,
7, 8, 5, 3, 1
2 3

Exercise 3
4 • Preorder Traversal: 1, 2, 4, 7,
3, 5, 6, 8

• Inorder Traversal: 4, 7, 2, 1,
5 6 5, 3, 8, 6

• Postorder Traversal: 7, 4, 2,
5, 8, 6, 3, 1
7 8
Exercise 4
• Preorder Traversal: 1, 2, 3, 5,
Solutions 4, 6, 7, 8

• Inorder Traversal: 5, 3, 2, 1,
Exercise 1
4, 7, 6, 8
• Preorder Traversal: 1, 2, 4, 5,
3, 6, 7 • Postorder Traversal: 5, 3, 7,
8, 6, 4, 2, 1
• Inorder Traversal: 4, 2, 5, 1,
6, 3, 7 Exercise 5
• Postorder Traversal: 4, 5, 2, • Preorder Traversal: 1, 2, 4, 5,
6, 7, 3, 1 6, 7, 8,3

• Inorder Traversal: 2, 5, 4, 7,
Exercise 2 6, 8, 1, 3

• Preorder Traversal: 1, 2, 4, 6, • Postorder Traversal: 5, 7, 8,


3, 5, 7, 8 6, 4, 2, 3, 1

You might also like