2.3.1 BIG O NOTATIONS STIFDF

21 flashcardsby Sabs2023
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
What should you always think abt when developing an algorithm
Space complexity
Time complexity
2
Time complexity?
Indicates how much time an algorithm takes to solve a problem
3
Space complexity
Indicates how much memory the algorithm uses
4
Big o notation?
Expresses complexity of algorithm and considers worst case scenario
- Remove all terms except one with largest factor/exponent
- Remove any constants
5
Simplify this complexity: 5 +3n + 1
3n then n
6
Worst case scenario
When we happen to choose the input which requires the most time
7
Con_?
Constant complexity = O(1) = No matter how big/small the list/input size is, it takes the same amount of time
BEST
8
Lin_?
Linear complexity = O(N) = As list/input size increases , time taken increases proportionally
Okay/mid
9
Log_?
Logarithmic complexity = O(log N) = As input size/list increases, time taken increases at slower rates
Great
10
Pol_?
Polynomial/quadratic =O(N$^{2}$) = As list/input size increases, time taken increases proportionally to the square of list/input size
Not great
11
Ex_?
Exponential = O(2$^{N}$) =Each extra input added(from 2 to 3 etc), DOUBLES time taken
WORST
12
From best to worst sort the complexities out
BEST:
CONSTANT
LOGARITHMIC
LINEAR
POLYNOMIAL/QUADRATIC

EXPONENTIAL
WORST
13
Calculate these functions complexity and then calculate its actual complexity
O(1) + O(n) + O(n^2) + O(1)
Becomes O(n^2)
14
Bubble sort and insertion average and worst time complexity?
Polynomial = O(N$^2$) = for both
15
Merge sort average and worst time complexity
Linearithmic = O(n log N)
16
Quick sort average and worst time complixity
Average = Linearithmic
WORST = Polynomial = O(N$^2$)
17
Image occlusion: name the hidden labels
18
Linear search average and worst?
Linear = O(N) = for both
19
Binary search array average and worst?
Logarithmic = O(log N) = for both
20
Hashing average and worst?
Average = constant = O(1)
WORST = Linear = O(N) considers overflow list
21
Image occlusion: name the hidden labels
Study all 21 cards for free