...

/

Comparing Running times

Comparing Running times

Learn how running times, expressed as functions, can be compared by examining the function growth.

Alice and Bob are trying to solve the same problem, and they both come up with different algorithms for it.

They are able to express their running times as two functions. But can they compare the two functions and see if one is better than the other?

One has a running time of 3n+53n+5 time units, and the other has a running time of 2n+100002n+10000 time units. Is the performance of both algorithms similar, or is one better than the other?

To be able to make this kind of assessment, we need to compare the two polynomials and look at how the functions grow.

Comparing how different functions grow

Let’s look at how some functions grow as the value of nn grows larger.

nn 15n15n n2
...