Big O notation Flashcards

1
Q

Big O Constant Time (random access in array)

A

O(1) Constant Time

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

Big O Linear Time (Delete value linked List)

A

O(n) Linear Time (Looping Arrays, Lists)

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

What is Big O Notation

A

1) The efficiency of your Algorithm

2) Used to describe run-time characteristics of our data structure and algorithms

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

What is linear time

A

Where the number of elements in the data structure increased and the operation takes longer (looping, etc)

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

What is faster O(n) or O(2^n)

A

O(n)

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

Big O What is Logarithmic (search algorithms)

A

O(Log n) Logarithmic

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

Big O What is Quasilinear ( Sorting algorithms)

A

O(n log n) Quasilinear

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

Big O What is Quadratic (Nested Loops )

A

O(n powerOf 2) Quadratic

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

Exponential (Recursion, Fibonacci series) Gets slower the more that is calculated

A

O(2 powerOf n) Recursion,

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

Operations that takes the same amount of time regardless of the number of elements

A

O(1)

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

Iteration through a collection (for loop, while loop)

A

O(n)

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

Looping through the same collection x2 (nested)

A

O(n powerOf 2)

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

Fibonacci series - recursion (branches squared depth)

A

O(2 powerOf n)

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

Search sorted array (binary tree)

A

O(log n)

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

simplify O(n powerOf 2 + n)

A

O(n powerOf) Drop non-dominated terms

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

simplify O(3n)

A

O(n) Drop constants

17
Q

Describe two Loops

A

O(n+m)

18
Q

Nested for Loop two different arrays

A

O(n*m)

19
Q

Nest for Loop with same array

A

O(n powerOf 2)

20
Q

Big O

Constant

A

O(1)

21
Q

Big O

Logarithmic

A

O(log n)

22
Q

Big O

Linear

A

O(n)

23
Q

Big O

Log Linear

A

O(n log n)

24
Q

Big O

Quadratic

A

O(n^2)

O(n powerOf 2)

25
Q

Big O

Cubic

A

O(n^3)

26
Q

Big O

Exponential

A

O(2^n)

27
Q

Big O simplify

O(1) + (O(n/2)) = O (1/2 *n) + O(10)

print 1st[0] # O(1)

midpoint = len(1st)/2 # O(1/2 * n)

for val in list[:midpoint]:
print (val)

for x in range(10) # O(10)
print(‘hello world’)

A

O(1) + (O(n/2)) = O (1/2 *n) + O(10)

# O(1 + n/2 + 10)
# AS IT GROWS lARGER 1 AND 10 BECOME INSUGNIFICATE 
#  o(n)
28
Q

Big O

n*n (two for loops)

A

n squared

O(n^2)

dangers for large inputs

29
Q

Big O

Only do an action once

A

O(1)

30
Q

Big O - Python

Lists

A

Indexing and Assigning

O(1)

31
Q

Big O - Python

Dictionary

A

O(1)