What is the best data structure to implement topological sort on directed graph?
A
Stack
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
Array
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
Heap
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
Queue
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution
The correct option is A Stack The best data structure used to implement topological sort is stack, since topological sort based on depth first traversal.