Big-O Flashcards
(46 cards)
What is known as Constant complexity?
1
What is known as Logarithmic complexity?
log(n)
What is known as Squared Logarithmic complexity?
[log(n)]^2
What is known as Fractional Polynomial complexity?
n^c [where 0<c<1]
What is known as Linear complexity?
n
What is known as Linearithmic complexity?
n log(n)
What is known as Quadratic complexity?
n^2
What is known as Exponential complexity?
2^n
What is known as Factorial complexity?
n!
What is the smallest complexity?
Constant, O(1)
What is the largest COMMON complexity?
Factorial, O(n!)
Which is larger:
n^2 or log(n)
n^2
Which is larger:
k^n (where k>3) or n^[log(log(n))]
k^n (where k>3)
Which is larger:
n^n or n!
n^n
Which is larger:
n log(n) or log(n!)
n log(n)
Which is larger:
n^2^n or 2^n^2
n^2^n
Which is larger:
2^n or 2^2n
2^2n
Which is larger:
[log(n)]^2 or n^k (where k>3)
n^k (where k>3)
Which is larger:
n^c (where 0<c<1) n^2
n^2
Which is larger:
2^n^2 or n^n
n^n
Which is larger:
2^n or n!
n!
What is the Big-O of this code snippet, and how many times is PCO run?
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k< n; k++) {
PCO } } }
PCO = n * n * n = n^3
O(n^3)
What is the Big-O of this code snippet, and how many times is PCO run?
for (int i = 0; i < n; i++) {
for (int k = 0; k < n; j++) { PCO }
for (int k = 0; k< n; k++) { PCO }
}
PCO = n * (n + n) = 2n^2
O(n^2)
What is the Big-O of this code snippet, and how many times is PCO run?
for (int i = 0; i < n; i++) { PCO }
PCO = n
O(n)