Graph Theory37 sections · 1633 units
Open in Course

Pattern - Uniqueness

Is there only one way?

Problem: Sequence Reconstruction. Task: Check if the topological sort is unique. Logic: In Kahn's algorithm, if at any point the queue size is greater than 11, it means you have choices. Choice implies multiple valid orderings. To ensure uniqueness, the queue size must always be 11 throughout the entire process.

This means there is only one valid next node at every step. You check this condition inside your BFS loop.