Question

I have a graph with a large amount of edges to vertices n(n-1)/2. If I have 16 verticies 16^2 + 120 is 376 and 120 * log2(16) is 480. So here V^2 is faster? Is my calculations correct and if they are when will the size of vertices reach the point to E log v being faster?

Was it helpful?

Solution

The assymptotic notation informs you about how execution time grows with growing input, and that does not let you do such comparisons like "for V = 10, E = 15 I get that value smaller than the other".

If you have two algorithms, with time complexities O(V^2 + E) and O(E log V), the only thing you can say is that the first one works better for dense graphs and the other for sparse graphs (by supposing V^2 = E for dense and V = E for sparse).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top