0 0 votes Which is the best data structure to implement topological sort on directed graph? Heap Stack queue Array Algorithms topological-sort made-easy-test-series graph-algorithms + – Nandkishor3939 2.2k views answer comment Share Follow Print See all 7 Comments 7 7 Comments reply Show 4 previous comments Ashish Lakhmani commented Jun 24, 2019 reply Follow flag I think the question is ambiguous because both stack and queue can be used to give correct answers efficiently. Queue : We use an array of in-degrees for all the vertices and a Queue. Stack : We use dfs and Stack (given in geeksforgeeks). 0 0 replyShare Satbir commented Jun 24, 2019 reply Follow flag Queue will not give correct result in all the cases. 0 0 replyShare Ashish Lakhmani commented Jun 28, 2019 reply Follow flag Please refer to this article : https://www.geeksforgeeks.org/topological-sorting-indegree-based-solution/ 1 1 replyShare Please log in or register to add a comment.
0 0 votes topological sort application dfs dfs used stack answer is stack gorya506 answered Aug 18, 2019 gorya506 comment Share Follow 0 reply Please log in or register to add a comment.