Problem Statement
Which of the following are properties of a binary tree?
Explanation
In a binary tree, each node has at most two children. The first child is called the left subtree and the second child is called the right subtree. These are fundamental properties of binary trees.
The root can be null in an empty tree, so option C is incorrect. Binary trees are hierarchical structures where each node can have zero, one, or two children. The left and right terminology is a standard convention used universally in computer science.
Code Solution
SolutionRead Only
// Binary Tree Node Structure
class TreeNode {
int data;
TreeNode left; // First subset - left subtree
TreeNode right; // Second subset - right subtree
TreeNode(int data) {
this.data = data;
this.left = null;
this.right = null;
}
}
// Example Binary Tree:
// 1
// / \
// 2 3
// / \
// 4 5
// Node 1: left=2, right=3
// Node 2: left=4, right=5
// Node 3: left=null, right=nullPractice Sets
This question appears in the following practice sets:
