DeepFrontend
Learning Paths
Practice
System Design & DS
Design Studio
Data Structures Curriculum
Real-World Case Studies
Careers
Job Board
Resume Builder
Blog
Sign in
Search
⌘K
Go Pro
Loading compiler resources...
Interview Prep Quiz Practice
Active Recall Drill Session
← Exit Session
Question 1 of 1
hard
Interview Prep
In the topoSort implementation from the Concept section, why is a node pushed onto 'order' AFTER visiting its dependencies, followed by a final .reverse()?
A
It's arbitrary and could be done before with the same result
B
A node can only safely appear before its dependents once all its own dependencies are already accounted for, which post-order DFS plus a reversal achieves
C
Reversing has no effect on correctness, it's purely stylistic
D
JavaScript arrays require reversal for performance reasons
Check Answer