0
0
DSA C++programming~20 mins

Tree Terminology Root Leaf Height Depth Level in DSA C++ - Practice Problems & Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
šŸŽ–ļø
Tree Terminology Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
Identify the root node in a tree
In a tree data structure, which node is called the root?
AThe node with the lowest height
BThe node with no parent
CThe node with no children
DThe node with the highest depth
Attempts:
2 left
šŸ’” Hint
Think about the starting point of the tree.
ā“ Predict Output
intermediate
1:30remaining
Find the leaf nodes in a tree
Given the following tree nodes and their children, which nodes are leaves?
DSA C++
Node 1: children = [2, 3]
Node 2: children = [4]
Node 3: children = []
Node 4: children = []
A[1, 2]
B[1, 4]
C[2, 3]
D[3, 4]
Attempts:
2 left
šŸ’” Hint
Leaves have no children.
ā“ Predict Output
advanced
1:30remaining
Calculate the height of a node
What is the height of node 2 in the following tree? Structure: 1 ā”œā”€ 2 │ └─ 4 └─ 3
DSA C++
Height is the number of edges on the longest path from the node to a leaf.
A0
B2
C1
D3
Attempts:
2 left
šŸ’” Hint
Count edges from node 2 down to its farthest leaf.
ā“ Predict Output
advanced
1:30remaining
Determine the depth of a node
What is the depth of node 4 in the tree below? Structure: 1 ā”œā”€ 2 │ └─ 4 └─ 3
DSA C++
Depth is the number of edges from the root to the node.
A2
B1
C0
D3
Attempts:
2 left
šŸ’” Hint
Count edges from root (1) to node 4.
🧠 Conceptual
expert
2:00remaining
Identify the level of a node in a tree
In a tree, what does the level of a node represent?
AThe number of edges from the root plus one
BThe number of children the node has
CThe height of the node
DThe number of leaf nodes in the subtree
Attempts:
2 left
šŸ’” Hint
Level is closely related to depth but starts counting from 1.