Skip to content

Conversation

@caojoshua
Copy link
Contributor

See https://en.wikipedia.org/wiki/Kosaraju%27s_algorithm

I found a couple of articles online that suggest that the space complexity is O(V), for creating a the visited array and priority stack. I think it should actually be O(V + E), because the transposed graph needs to hold E edges. I think my analysis is correct, but have not found any sources online to confirm it.

Copy link
Contributor

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution. Your space complexity analysis is correct, the transposed graph requires O(V + E) space in this implementation. (Other graph data structures might store both in- and out-edges for each node, hence not needing auxiliary space for the transposition.)

@raklaptudirm raklaptudirm merged commit 6e78b6c into TheAlgorithms:master Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants