Bird
Raised Fist0

Given the final leaves deque contains nodes [2, 3] after leaf trimming, which of the following edge lists could produce this result for n=4?

hard🔄 Reverse Engineer Q9 of Q15
Topological Sort - Minimum Height Trees (Centroid by Trimming)
Given the final leaves deque contains nodes [2, 3] after leaf trimming, which of the following edge lists could produce this result for n=4?
A[[0,1],[1,2],[1,3]]
B[[0,1],[0,2],[0,3]]
C[[0,2],[2,3],[3,1]]
D[[0,1],[1,2],[2,3]]
Step-by-Step Solution
Solution:
  1. Step 1: Understand leaf trimming output

    Leaves [2,3] remain means nodes 2 and 3 are centroids after trimming.
  2. Step 2: Analyze each edge list

    [[0,1],[1,2],[2,3]] forms a chain 0-1-2-3; trimming leaves 0 and 1 leaves 2 and 3 as centroids.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Chain structure matches final leaves [2,3] [OK]
Quick Trick: Leaves after trimming reveal chain ends [OK]
Common Mistakes:
MISTAKES
  • Choosing star graphs where only one centroid remains
Trap Explanation:
PITFALL
  • Candidates confuse star and chain structures, misidentifying centroids.
Interviewer Note:
CONTEXT
  • Tests reverse reasoning from output to input graph
Master "Minimum Height Trees (Centroid by Trimming)" in Topological Sort

3 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Topological Sort Quizzes