Skip to main content
Share Your Experience: Take the 2024 Developer Survey
5 votes

Big-O time complexity for this code snippet

You are right, the two innermost loops perform $\Theta(\log n)$ iterations each, so we have a total of $\Theta(\log^2 n)$ iterations, which are repeated $\Theta(n)$ times in the outer loop, which ...
SilvioM's user avatar
  • 898
2 votes

What is the Time Complexity of Least Topological Ordering?

Yes, the best complexity one can get for this problem is O(V*log(V) + E). Therefore, your approach is correct. Congrats :) From a practical standpoint, the average ...
Radu Andrei Vaida's user avatar
1 vote

3sat to clique reduction program

Let 3-SAT formula $\phi$ be $C_1 \wedge C_2 \wedge \dots \wedge C_m$, where $C_i$ is a clause consisting of the disjunction of three literals: $(\ell_i^1 \vee \ell_i^2 \vee \ell_i^3)$. We can create ...
Steven's user avatar
  • 29.5k

Only top scored, non community-wiki answers of a minimum length are eligible