## Can an O(n) algorithm ever exceed O(n^2) in terms of computation time?

Asymptotic complexity (which is what both big-O and big-Theta represent) completely ignores the constant factors involved – it’s only intended to give an indication of how running time will change as the size of the input gets larger. So it’s certainly possible that an Θ(n) algorithm can take longer than an Θ(n2) one for some … Read more

## What does “O(1) access time” mean? [duplicate]

You’re going to want to read up on Order of complexity. http://en.wikipedia.org/wiki/Big_O_notation In short, O(1) means that it takes a constant time, like 14 nanoseconds, or three minutes no matter the amount of data in the set. O(n) means it takes an amount of time linear with the size of the set, so a set … Read more

## What is the Big-O of a nested loop, where number of iterations in the inner loop is determined by the current iteration of the outer loop?

Yep, it’s still O(n^2), it has a smaller constant factor, but that doesn’t affect O notation.

## Time complexity of nested for-loop

Yes, nested loops are one way to quickly get a big O notation. Typically (but not always) one loop nested in another will cause O(n²). Think about it, the inner loop is executed i times, for each value of i. The outer loop is executed n times. thus you see a pattern of execution like … Read more

## What is the difference between Θ(n) and O(n)?

Short explanation: If an algorithm is of Θ(g(n)), it means that the running time of the algorithm as n (input size) gets larger is proportional to g(n). If an algorithm is of O(g(n)), it means that the running time of the algorithm as n gets larger is at most proportional to g(n). Normally, even when … Read more