Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Big O Measure Memory Requirments Or Just Speed?

Tags:

I often here people talk about Big O which measures algorithms against each other

Does this measure clock cycles or space requirements.

If people want to contrast algorithms based on memory usage what measure would they use

like image 782
Jack Kada Avatar asked Jul 12 '10 16:07

Jack Kada


People also ask

What does Big O measure?

Big O Notation is a way to measure an algorithm's efficiency. It measures the time it takes to run your function as the input grows. Or in other words, how well does the function scale. There are two parts to measuring efficiency — time complexity and space complexity.

Under what situation can we ignore Big O Notation?

We may ignore any powers of n inside of the logarithms. The set O(log n) is exactly the same as O(log(nc)). The logarithms differ only by a constant factor (since log(nc) = c log n) and thus the big O notation ignores that. Similarly, logs with different constant bases are equivalent.

Is Big O the worst case?

Worst case — represented as Big O Notation or O(n)Big-O, commonly written as O, is an Asymptotic Notation for the worst case, or ceiling of growth for a given function. It provides us with an asymptotic upper bound for the growth rate of the runtime of an algorithm.


2 Answers

If someone says "This algorithm runs in O(n) time", he's talking about speed. If someone says "This algorithm runs in O(n) space", he's talking about memory.

If he just says "This algorithm is O(n)", he's usually talking about speed (though if he says it during a discussion about memory, he's probably talking about memory).

If you're not sure which one someone's talking about, ask him.

like image 132
sepp2k Avatar answered Nov 24 '22 09:11

sepp2k


Short answer : you have 'Big O in space" and "Big O in time".

Long answer: Big O is just a notation, you can use it in whatever context you want.

like image 34
Alexandre C. Avatar answered Nov 24 '22 08:11

Alexandre C.