13
Big O notation
Here’s another example. Binary search needs log
n
operations to check
a list of size
n
. What’s the running time in Big O notation? It’s O(log
n
).
In general, Big O notation is written as follows.
This tells you the number of operations an algorithm will make. It’s
called Big O notation because you put a “big O” in front of the number
of operations (it sounds like a joke, but it’s true!).
Now let’s look at some examples. See if you can figure out the run time
for these algorithms.
Dostları ilə paylaş: