1
$\begingroup$

I followed an explanation of Kosaraju's and Tarjan's strongly-connected components algorithms, and they say that both have O(|V|+|E|) time complexity.

That didn't make sense to me since Kosaraju uses two DFS passes and computes the transposed graph, but Tarjan's use only one DFS.

$\endgroup$
  • $\begingroup$ You seem to think that Landau notation is way more useful/informative than it really is. $\endgroup$ – Raphael Aug 23 '16 at 15:12
0
$\begingroup$

they say that both have O(|V|+|E|) time complexity.

that didn't make sens for me since Kosaraju use two dfs pass and compute transpose graph, but Tarjan's use only one dfs

If you check the definition of Landau notation you will see that it does not say which function is smaller, that is (here) which algorithm is faster. It ignores constant factors.

Both algorithms have running times in $\Theta(|V| + |E|)$; that does not preclude one of them being $2^{100}$ times faster than the other for all $n \leq 2^{100}$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.