176k views
0 votes
Which of the following shows a list of Big-Oh running times in order from slowest to fastest?

O(1), O(N), O(N2), O(logN), O(2N)

O(1), O(N), O(N3), O(2N), O(N!)

O(logN), O(N!), O(N2), O(N3), O(2N)

O(N!), O(2N), O(N2), O(N), O(logN)

User Cervo
by
7.7k points

2 Answers

1 vote

Answer:

O(N!), O(2N), O(N2), O(N), O(logN)

Step-by-step explanation:

User Leonardo Marques
by
8.0k points
3 votes

Answer:

O(N!), O(2N), O(N2), O(N), O(logN)

Step-by-step explanation:

N! grows faster than any exponential functions, leave alone polynomials and logarithm. so O( N! ) would be slowest.

2^N would be bigger than N². Any exponential functions are slower than polynomial. So O( 2^N ) is next slowest.

Rest of them should be easier.

N² is slower than N and N is slower than logN as you can check in a graphing calculator.

NOTE: It is just nitpick but big-Oh is not necessary about speed / running time ( many programmers treat it like that anyway ) but rather how the time taken for an algorithm increase as the size of the input increases. Subtle difference.

User DUman
by
7.6k points