Binary Trees Quiz
40 comprehensive questions exploring binary tree fundamentals — with 16 code examples covering definitions, properties, full/complete/perfect trees, and basic implementations in this cpp quiz.
Question 1
What is a binary tree?
Question 2
In a binary tree, what is the maximum number of nodes at level k (starting from level 0 at root)?
Level 0: 1 node
Level 1: 2 nodes
Level 2: 4 nodes
Level k: ?Question 3
What is a full binary tree?
Question 4
What is a complete binary tree?
Complete tree: nodes filled left to right
Incomplete tree: gaps in the structureQuestion 5
What is a perfect binary tree?
Question 6
In a binary tree with n nodes, what is the minimum possible height?
Height = longest path from root to leaf
Minimum height for n nodes: floor(log2(n))Question 7
What is the maximum number of nodes in a binary tree of height h?
Question 8
In a complete binary tree, where would the parent of a node at position i be located?
Array indices: 0-based
Left child: 2*i + 1
Right child: 2*i + 2
Parent of i: ?Question 9
What is the relationship between the number of leaf nodes and internal nodes in a full binary tree?
Question 10
How many different binary trees can be formed with 3 nodes?
Nodes: A, B, C
Possible trees: 5 different structuresQuestion 11
What is a skewed binary tree?
Question 12
In a binary tree, what is the maximum number of nodes at level k in a tree of height h?
Height h means levels 0 to h
Level k has at most 2^k nodesQuestion 13
What is the height of a single-node binary tree?
Tree with one node: root
Height: 0Question 14
How many edges does a binary tree with n nodes have?
Question 15
What is the minimum number of nodes in a binary tree of height h?
Height h: minimum nodes = h + 1
(skewed tree)Question 16
In a complete binary tree with n nodes, what is the height of the tree?
Complete tree: floor(log2(n))Question 17
What distinguishes a binary tree from a general tree?
Question 18
In a perfect binary tree of height h, how many nodes are there?
Question 19
What is the balance factor of a node in binary tree analysis?
Balance factor = height(left) - height(right)Question 20
How many different binary search trees can be formed with keys 1, 2, 3?
Question 21
What is the maximum height of a binary tree with n nodes?
Skewed tree: height = n-1Question 22
In a binary tree, what is the relationship between internal nodes and total nodes?
Question 23
What is a degenerate binary tree?
All nodes have one child: linear structureQuestion 24
How does the height of a complete binary tree relate to the number of nodes?
Question 25
What is the significance of the binary tree property in algorithm design?
Binary choices: left/right, true/false, yes/noQuestion 26
In a full binary tree with n internal nodes, how many leaves are there?
Question 27
What is the minimum height of a binary tree with n nodes?
Balanced tree: height ≈ log2(n)Question 28
How many leaves can a binary tree with n nodes have at most?
Question 29
What is the structural difference between complete and perfect binary trees?
Perfect: all levels full
Complete: last level left-filledQuestion 30
In terms of space complexity, how do binary trees compare to arrays for storing hierarchical data?
Question 31
What is the Catalan number's significance in binary tree enumeration?
C_n = number of binary trees with n nodes
C_3 = 5Question 32
How does the height of a binary tree affect algorithm performance?
Question 33
What is the relationship between a binary tree's height and its balance?
Balanced: height ≈ log2(n)
Unbalanced: height ≈ nQuestion 34
In a binary tree implementation, what is the significance of the null pointer representation?
TreeNode* left = nullptr;
TreeNode* right = nullptr;Question 35
How do binary trees support recursive algorithm design?
Question 36
What is the impact of tree shape on binary tree operations?
Balanced: O(log n)
Skewed: O(n)Question 37
In binary tree analysis, what does the term 'degeneracy' refer to?
Question 38
How does the binary tree structure enable efficient searching algorithms?
Binary search: compare, go left or rightQuestion 39
What is the fundamental property that distinguishes binary trees from other tree types in terms of structural constraints?
Question 40
Considering the various properties and classifications of binary trees, which structural characteristic most directly influences the efficiency of tree-based algorithms and data structure performance in practice?
