0
0
Data Structures Theoryknowledge~20 mins

Tree traversals (inorder, preorder, postorder) in Data Structures Theory - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Tree Traversal Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify the traversal order

Given a binary tree, which traversal visits the root node first, then the left subtree, and finally the right subtree?

ALevel-order traversal
BInorder traversal
CPostorder traversal
DPreorder traversal
Attempts:
2 left
💡 Hint

Think about which traversal starts by visiting the root node before its children.

📋 Factual
intermediate
2:00remaining
Output of inorder traversal

What is the output sequence of an inorder traversal on the following binary tree?

2
/ \
1 3

A[2, 1, 3]
B[1, 2, 3]
C[3, 2, 1]
D[1, 3, 2]
Attempts:
2 left
💡 Hint

Inorder traversal visits left subtree, root, then right subtree.

🔍 Analysis
advanced
2:00remaining
Determine postorder traversal output

Consider this binary tree:

A
/ \
B C
/ / \
D E F

What is the postorder traversal output?

A[B, D, A, E, F, C]
B[A, B, D, C, E, F]
C[D, B, E, F, C, A]
D[D, B, C, E, F, A]
Attempts:
2 left
💡 Hint

Postorder traversal visits left subtree, right subtree, then root.

Comparison
advanced
2:00remaining
Compare preorder and postorder traversals

Which statement correctly compares preorder and postorder traversals of a binary tree?

APreorder visits the root before its subtrees; postorder visits the root after its subtrees.
BPreorder visits the root after its subtrees; postorder visits the root before its subtrees.
CBoth preorder and postorder visit the root at the same time.
DPreorder and postorder always produce the same node sequence.
Attempts:
2 left
💡 Hint

Think about when the root node is visited in each traversal.

Reasoning
expert
2:00remaining
Number of nodes visited in preorder traversal

A binary tree has 7 nodes. How many nodes will be visited during a complete preorder traversal?

A7
B6
C8
DDepends on the tree structure
Attempts:
2 left
💡 Hint

Traversal visits every node exactly once.