Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a binary tree?
A binary tree is a structure made of nodes where each node has at most two children called left and right child.
Click to reveal answer
beginner
Define the term 'root' in a binary tree.
The root is the topmost node of a binary tree. It is the starting point from which all other nodes descend.
Click to reveal answer
beginner
What is a 'leaf' node?
A leaf node is a node that has no children. It is at the bottom of the tree.
Click to reveal answer
beginner
Explain the term 'parent' and 'child' in a binary tree.
A parent node is a node that has one or two children nodes. A child node is a node that descends from a parent node.
Click to reveal answer
intermediate
What does 'subtree' mean in a binary tree?
A subtree is any node in the tree along with all its descendants. It forms a smaller tree inside the main tree.
Click to reveal answer
In a binary tree, how many children can a node have at most?
AOne
BThree
CTwo
DUnlimited
✗ Incorrect
By definition, each node in a binary tree can have at most two children.
What is the name of the node at the very top of a binary tree?
ALeaf
BParent
CChild
DRoot
✗ Incorrect
The root is the topmost node from which all other nodes descend.
Which node has no children in a binary tree?
ALeaf
BParent
CRoot
DSubtree
✗ Incorrect
Leaf nodes have no children and are at the bottom of the tree.
What do we call a node that has one or two nodes descending from it?
AParent
BLeaf
CChild
DRoot
✗ Incorrect
A parent node has children nodes descending from it.
What is a subtree in a binary tree?
AA node with no children
BA node and all its descendants
CThe entire tree
DOnly the root node
✗ Incorrect
A subtree includes a node and all nodes below it, forming a smaller tree.
Describe the main parts of a binary tree and their roles.
Think about the top node, nodes with children, nodes without children, and smaller trees inside.
You got /4 concepts.
Explain how the terms 'parent', 'child', and 'leaf' relate to each other in a binary tree.
Consider the family-like relationship between nodes.
You got /3 concepts.
Practice
(1/5)
1. In a binary tree, what do we call the topmost node that has no parent?
easy
A. Root
B. Leaf
C. Internal node
D. Child
Solution
Step 1: Understand the position of nodes in a binary tree
The topmost node in a binary tree is the starting point and has no parent node above it.
Step 2: Identify the term for the topmost node
This node is called the root because it is the base from which all other nodes branch out.
Final Answer:
Root -> Option A
Quick Check:
Top node = Root [OK]
Hint: Top node with no parent is always the root [OK]
Common Mistakes:
Confusing root with leaf
Thinking root has a parent
Calling root a child
2. Which of the following correctly describes a leaf node in a binary tree?
easy
A. The topmost node
B. A node with exactly two children
C. A node with one child
D. A node with no children
Solution
Step 1: Recall the definition of a leaf node
A leaf node is a node that does not have any children, meaning it is at the end of a branch.
Step 2: Match the definition with the options
A node with no children states the node has no children, which matches the leaf node definition.
Final Answer:
A node with no children -> Option D
Quick Check:
Leaf node = no children [OK]
Hint: Leaf nodes have zero children, no branches below [OK]
Common Mistakes:
Thinking leaf has children
Confusing leaf with root
Assuming leaf has one child
3. Consider this binary tree node description: Node A has two children: Node B (left) and Node C (right). Node B has no children. Node C has one child: Node D (left). Which of these nodes is an internal node?
medium
A. Node B only
B. Node D only
C. Node A and Node C
D. Node A only
Solution
Step 1: Define internal nodes
Internal nodes have at least one child. Leaf nodes have none.
Step 2: Analyze each node's children
Node A has two children (B and C), so it is internal. Node B has no children, so it is a leaf. Node C has one child (D), so it is internal. Node D has no children, so it is a leaf.
Final Answer:
Node A and Node C -> Option C
Quick Check:
Internal nodes = nodes with children [OK]
Hint: Internal nodes have one or two children, leaves have none [OK]
Common Mistakes:
Calling leaf nodes internal
Ignoring nodes with one child
Confusing node labels
4. Identify the error in this statement about binary trees: "A leaf node can have one child."
medium
A. Leaf nodes cannot have any children, so the statement is false.
B. Leaf nodes are always the root, so the statement is false.
C. Leaf nodes can have two children, so the statement is false.
D. Leaf nodes must have exactly one child, so the statement is true.
Solution
Step 1: Recall the definition of a leaf node
A leaf node is defined as a node with no children at all.
Step 2: Evaluate the statement
The statement says a leaf node can have one child, which contradicts the definition. Therefore, the statement is false.
Final Answer:
Leaf nodes cannot have any children, so the statement is false. -> Option A
Quick Check:
Leaf node = no children [OK]
Hint: Leaf nodes have zero children, never one [OK]
Common Mistakes:
Thinking leaf can have children
Confusing leaf with internal node
Misunderstanding node roles
5. You have a binary tree where every internal node has exactly two children, and all leaves are at the same depth. What is this type of binary tree called?
hard
A. Complete binary tree
B. Perfect binary tree
C. Balanced binary tree
D. Full binary tree
Solution
Step 1: Understand the definitions of binary tree types
A full binary tree has every node with 0 or 2 children. A complete binary tree is filled level by level left to right. A balanced binary tree has heights of subtrees differ by at most one. A perfect binary tree is full and all leaves are at the same depth.
Step 2: Match the given conditions
The tree described has every internal node with exactly two children (full) and all leaves at the same depth, which matches the perfect binary tree definition.
Final Answer:
Perfect binary tree -> Option B
Quick Check:
Full + all leaves same depth = Perfect tree [OK]
Hint: Full + all leaves same depth = Perfect binary tree [OK]