Recall & Review
beginner
What is a binary tree node?
A binary tree node is a basic unit of a binary tree that contains data and references to at most two child nodes: left and right.
Click to reveal answer
beginner
What are the main parts of a binary tree node?
A binary tree node has three main parts:
- Data: stores the value.
- Left child: reference to the left subtree.
- Right child: reference to the right subtree.
Click to reveal answer
beginner
TypeScript code snippet: Define a simple binary tree node class.
class TreeNode {
value: number;
left: TreeNode | null;
right: TreeNode | null;
constructor(value: number) {
this.value = value;
this.left = null;
this.right = null;
}
}Click to reveal answer
beginner
Why do left and right child references sometimes hold null?
Because a node may not have a left or right child, so the reference is set to null to show the absence of a child node.
Click to reveal answer
beginner
How does a binary tree node relate to real-life family trees?
Like a person in a family tree has parents and children, a binary tree node has a value and can have up to two children nodes, representing branches.
Click to reveal answer
What does a binary tree node typically contain?
✗ Incorrect
A binary tree node contains data and references to at most two children: left and right.
In TypeScript, what type should the left and right child references have in a binary tree node?
✗ Incorrect
Left and right children can be either another TreeNode or null if no child exists.
If a node has no left child, what is the left reference set to?
✗ Incorrect
Null is used to indicate the absence of a child node.
How many children can a binary tree node have at most?
✗ Incorrect
By definition, a binary tree node can have up to two children.
Which of these is NOT a part of a binary tree node?
✗ Incorrect
A basic binary tree node does not usually store a parent reference.
Describe the structure of a binary tree node and its components.
Think about what each node holds and how it connects to others.
You got /4 concepts.
Explain why left and right child references can be null in a binary tree node.
Consider what happens when a node has no children.
You got /3 concepts.