Big-O Flashcards

(46 cards)

1
Q

What is known as Constant complexity?

A

1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is known as Logarithmic complexity?

A

log(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is known as Squared Logarithmic complexity?

A

[log(n)]^2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is known as Fractional Polynomial complexity?

A

n^c [where 0<c<1]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is known as Linear complexity?

A

n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is known as Linearithmic complexity?

A

n log(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is known as Quadratic complexity?

A

n^2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is known as Exponential complexity?

A

2^n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is known as Factorial complexity?

A

n!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the smallest complexity?

A

Constant, O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the largest COMMON complexity?

A

Factorial, O(n!)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which is larger:
n^2 or log(n)

A

n^2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which is larger:
k^n (where k>3) or n^[log(log(n))]

A

k^n (where k>3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which is larger:
n^n or n!

A

n^n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which is larger:
n log(n) or log(n!)

A

n log(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which is larger:
n^2^n or 2^n^2

A

n^2^n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Which is larger:
2^n or 2^2n

A

2^2n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Which is larger:
[log(n)]^2 or n^k (where k>3)

A

n^k (where k>3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Which is larger:
n^c (where 0<c<1) n^2

20
Q

Which is larger:
2^n^2 or n^n

21
Q

Which is larger:
2^n or n!

22
Q

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 } } }

A

PCO = n * n * n = n^3
O(n^3)

23
Q

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 }
}

A

PCO = n * (n + n) = 2n^2
O(n^2)

24
Q

What is the Big-O of this code snippet, and how many times is PCO run?

for (int i = 0; i < n; i++) { PCO }

25
# What is the Big-O of this code snippet, and how many times is PCO run? for (int i = 1; i <= n; i++) { PCO }
PCO = n O(n)
26
# What is the Big-O of this code snippet, and how many times is PCO run? for (int i = 1; i < n; i++) { PCO }
PCO = n - 1 O(n)
27
# What is the Big-O of this code snippet, and how many times is PCO run? for (int i = 0; i < A; i++) { PCO } | When A is an Integer
PCO = A O(1)
28
# What is the Big-O of this code snippet, and how many times is PCO run? for (int i = 1; i <= A; i++) { PCO } | Where A is an Integer
PCO = A O(1)
29
# What is the Big-O of this code snippet, and how many times is PCO run? for (int i = 1; i < A; i++) { PCO } | Where A is an Integer
PCO = A - 1 O(1)
30
# What is the Big-O of this code snippet, and how many times is PCO run? for (int i = A; i > 0; i- -) { PCO } | Where A is an Integer
PCO = A O(1)
31
# What is the Big-O of this code snippet, and how many times is PCO run? for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) {PCO } } | Why is that?
PCO = 1 + 2 + ... + n = n(n+1)/2 O(n^2) i is 1, j runs once i is 2, j runs twice i is n, j runs n times | Sum of 1 -> n
32
# What is the Big-O of this code snippet, and how many times is PCO run? Sequence i: 1, 3, 5, ..., n N IS EVEN for (int i = 1; i <= n; i++) { PCO } | Why is that? Identify the sequence
Arithmetic sequence: First value is 1, Last value is n-1 (last odd before even n), Difference of adjacent values is 2 PCO = [Last - First]/Diff + 1 = [n - 1 - 1]/2 + 1 = n/2 O(n)
33
# What is the Big-O of this code snippet, and how many times is PCO run? Sequence i: 1, 3, 5, ..., n N IS ODD for (int i = 1; i <= n; i++) { PCO } | Why is that? Identify the sequence
Arithmetic sequence: First value is 1, Last value is n (n is odd), Difference of adjacent values is 2 PCO = [Last - First]/Diff + 1 = [n - 1]/2 + 1 = [n + 1]/2 O(n)
34
What can 9^n be simplified to?
k^n (where k > 3)
35
What can (n-3)! be simplified to?
n!
36
What can ln^3(n) be simplified to?
[log(n)]^3
37
What can 0.0008n^2 + 1000n^2log(n) + 1 be simplified to?
n^2logn
38
What can 2^3n be simplified to?
2^3n
39
What can root_3(n) be simplified to?
n^c (where 0 < c < 1)
40
What can 100000n^2 be simplified to?
n^2
41
What can 5log(n + 100)^1000 be simplified to?
log(n)^1000
42
Which is larger: nlog(n) or n^2log(n)
n^2log(n)
43
Which is larger: n^2 or n^2log(n)
n^2log(n)
44
Which is larger: log(n) or ln(n)
Neither, they are functionally the same
45
What should be the order of: A) 9^n B) (n-3)! C) ln^3(n) D) 0.0008n^2 + 1000n^2log(n) + 1 E) 2^3n F) root_3(n) G) 100000n^2 H) 5log(n+100)^1000
C < H < F < G < D < E < A < B
46
The implementation of an algorithm with input n where n is a power of 2. EXACTLY how many times is PCO run? for(int i = n; i > 0; i = i>>1) { for(int j = 0; j < i; j++) { for(int k = 8; k > 1; k- -) {PCO} } }
A is run log_2(n) + 1 times B is run i times C is run 8 times PCO = The sum of i * 7 where i = n, n/2, n/4 ... 1 = 7 * Geometric Series = 7 * The sum from k=0 to log_2(n) of n/2^k = 7(n + n/2 + n/4 + 1) = 7(2n-1) = 14n-7 = O(n)