A binary tree is a structure where each node has up to two children, called left and right. It looks like a family tree with parents and children.
Click to reveal answer
beginner
How do you create a node in a binary tree manually?
You create a node by making an object with a value and two pointers (or references) for left and right children, which can be empty (null).
Click to reveal answer
beginner
What does 'null' mean in the context of a binary tree node?
'Null' means the node does not have a child on that side. It is like an empty branch.
Click to reveal answer
beginner
Why do we need to link nodes manually when creating a binary tree?
Linking nodes manually connects parents to their children, building the tree shape step by step.
Click to reveal answer
beginner
What is the root node in a binary tree?
The root node is the top node of the tree. It has no parent and is the starting point to reach all other nodes.
Click to reveal answer
In a binary tree, how many children can each node have at most?
AUnlimited
BTwo
COne
DThree
✗ Incorrect
Each node in a binary tree can have up to two children: left and right.
What does a 'null' child pointer represent in a binary tree node?
AThe node is the root
BThe node has a child
CThe node is a leaf
DThe node has no child on that side
✗ Incorrect
'Null' means no child exists on that side of the node.
What is the first step when creating a binary tree manually?
ACreate the root node
BCreate leaf nodes
CDelete nodes
DTraverse the tree
✗ Incorrect
You start by creating the root node, the top of the tree.
How do you connect a parent node to its child in a binary tree?
ABy deleting the child node
BBy copying the child's value to the parent
CBy setting the parent's left or right pointer to the child node
DBy swapping the parent and child
✗ Incorrect
You link nodes by assigning the child node to the parent's left or right pointer.
What is the term for a node with no children in a binary tree?
ALeaf node
BRoot node
CParent node
DSibling node
✗ Incorrect
A leaf node has no children; it is at the end of a branch.
Explain how to create a simple binary tree manually with three nodes.
Think about making nodes and connecting them step by step.
You got /4 concepts.
Describe the role of 'null' in a binary tree node and why it is important.
Consider what happens when a node does not have a child.
You got /3 concepts.
Practice
(1/5)
1. What is the correct way to create a root node manually in a binary tree using C#?
easy
A. Node root = new Node(); root = 10;
B. Node root = Node(10);
C. Node root = new Node(); root.value = 10;
D. Node root = new Node(10);
Solution
Step 1: Understand Node creation syntax
In C#, to create an object, use the 'new' keyword followed by the constructor call with parameters.
Step 2: Apply correct syntax for root node
Using 'new Node(10)' correctly creates a node with value 10 assigned.
Final Answer:
Node root = new Node(10); -> Option D
Quick Check:
Use 'new' keyword with constructor to create node [OK]
Hint: Use 'new' keyword with constructor to create nodes [OK]
Common Mistakes:
Omitting 'new' keyword when creating node
Assigning value directly to node variable
Calling constructor without 'new'
2. Which of the following is the correct syntax to assign a left child node with value 5 to a root node named root?
easy
A. root.left = new Node(5);
B. root.left = Node(5);
C. root.left.value = 5;
D. root.left = 5;
Solution
Step 1: Understand child node assignment
Left child must be assigned a new Node object, not just a value.
Step 2: Use correct syntax to assign left child
Assigning 'root.left = new Node(5);' creates a new node with value 5 as left child.
Final Answer:
root.left = new Node(5); -> Option A
Quick Check:
Assign new Node object to left child [OK]
Hint: Assign new Node object, not just value, to child [OK]
Common Mistakes:
Assigning value directly instead of Node object
Omitting 'new' keyword
Trying to assign value to left property directly
3. Given the following code, what is the output of an inorder traversal (left, root, right)?
Node root = new Node(10);
root.left = new Node(5);
root.right = new Node(15);
root.left.left = new Node(3);
medium
A. [10, 5, 3, 15]
B. [3, 5, 10, 15]
C. [5, 3, 10, 15]
D. [3, 10, 5, 15]
Solution
Step 1: Understand inorder traversal order
Inorder visits left subtree, then root, then right subtree.
Step 2: Trace traversal on given tree
Left subtree of root (10) is node 5, which has left child 3. So traversal order is 3, 5, 10, 15.
Final Answer:
[3, 5, 10, 15] -> Option B
Quick Check:
Inorder = left, root, right [OK]
Hint: Inorder = left subtree, root, then right subtree [OK]
Common Mistakes:
Confusing preorder or postorder with inorder
Missing leftmost node in traversal
Listing nodes in insertion order
4. Identify the error in the following code that tries to create a binary tree:
Node root = new Node(20);
root.left = 10;
root.right = new Node(30);
medium
A. Right child node value is incorrect
B. Missing 'new' keyword when creating root node
C. Assigning integer directly to 'left' instead of a Node object
D. Root node value should be a string, not integer
Solution
Step 1: Check left child assignment
Left child must be a Node object, but code assigns integer 10 directly.
Step 2: Verify other parts
Root node and right child are correctly created with 'new Node()'.
Final Answer:
Assigning integer directly to 'left' instead of a Node object -> Option C
Quick Check:
Child nodes must be Node objects [OK]
Hint: Child nodes must be Node objects, not raw values [OK]
Common Mistakes:
Assigning raw values instead of Node objects
Forgetting 'new' keyword for node creation
Confusing node value type requirements
5. You want to manually create this binary tree:
8
/ \
3 10
/ \ \
1 6 14
/ \ /
4 7 13
Which code snippet correctly creates this tree?
hard
A. Node root = new Node(8);
root.left = new Node(3);
root.right = new Node(10);
root.left.left = new Node(1);
root.left.right = new Node(6);
root.left.right.left = new Node(4);
root.left.right.right = new Node(7);
root.right.right = new Node(14);
root.right.right.left = new Node(13);
B. Node root = new Node(8);
root.left = new Node(3);
root.right = new Node(10);
root.left.left = new Node(1);
root.left.right = new Node(6);
root.left.right.left = new Node(7);
root.left.right.right = new Node(4);
root.right.right = new Node(14);
root.right.right.left = new Node(13);
C. Node root = new Node(8);
root.left = new Node(3);
root.right = new Node(10);
root.left.left = new Node(1);
root.left.right = new Node(6);
root.left.right.left = new Node(4);
root.left.right.right = new Node(7);
root.right.left = new Node(14);
root.right.left.left = new Node(13);
D. Node root = new Node(8);
root.left = new Node(3);
root.right = new Node(10);
root.left.left = new Node(1);
root.left.right = new Node(6);
root.left.right.left = new Node(4);
root.left.right.right = new Node(7);
root.right.right = new Node(13);
root.right.right.left = new Node(14);
Solution
Step 1: Map tree structure to code
Root 8 has left 3 and right 10. Node 3 has children 1 and 6. Node 6 has children 4 and 7. Node 10 has right child 14, which has left child 13.
Step 2: Verify code matches tree
Node root = new Node(8);
root.left = new Node(3);
root.right = new Node(10);
root.left.left = new Node(1);
root.left.right = new Node(6);
root.left.right.left = new Node(4);
root.left.right.right = new Node(7);
root.right.right = new Node(14);
root.right.right.left = new Node(13); correctly assigns all nodes to their proper left or right children matching the tree diagram.
Final Answer:
Option A code snippet correctly creates the tree -> Option A
Quick Check:
Match tree structure exactly in code [OK]
Hint: Match each node's left/right child exactly as tree diagram [OK]
Common Mistakes:
Swapping left and right children
Assigning children to wrong parent nodes
Mixing up node values in assignments
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.