Dereferencing nullptr in root.left->val -> Option A
Quick Check:
Cannot access member via nullptr [OK]
Hint: Never dereference nullptr pointers [OK]
Common Mistakes:
Ignoring nullptr before dereference
Thinking struct needs semicolon error
Confusing pointer declaration syntax
5. You want to store a company's organizational chart where each employee can have multiple subordinates. Which data structure is best and why?
A) Array because it stores data contiguously
B) Tree because it naturally models multiple children per node
C) Linked List because it allows dynamic size
D) Stack because it supports last-in-first-out access
hard
A. Tree because it naturally models multiple children per node
B. Array because it stores data contiguously
C. Linked List because it allows dynamic size
D. Stack because it supports last-in-first-out access
Solution
Step 1: Understand organizational chart structure
Each employee can have multiple subordinates, forming a hierarchy with multiple children per node.
Step 2: Match data structure to hierarchy with multiple children
Trees allow nodes to have multiple children, perfect for this use case. Arrays and linked lists are linear, stacks are LIFO.
Final Answer:
Tree because it naturally models multiple children per node -> Option A
Quick Check:
Multiple children per node means Tree [OK]
Hint: Multiple children? Use Tree for hierarchy [OK]
Common Mistakes:
Choosing Array for hierarchy
Choosing Linked List for multiple children
Confusing Stack with hierarchical needs
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.