A Question on Time Complexity

quick question on time complexity here.

if you had two loops, one that runs, say, at O(N^2) and another at O(N^2) as well, would the complexity of the entire program be O(2*N^2) or just O(N^2)?

Both O(2\cdot N^2) and O(N^2) would be correct, but typically we would write the latter since it’s simpler. You can check this resource (or Wikipedia) for the actual definition of big O notation.

1 Like

Got it; Thanks for the insight!