2.?.? (Big O Notation) Flashcards
1
Q
What is the Big O Notation?
A
- A measure of the complexity of an algorithm
2
Q
What is O(1) - Constant?
A
- The operation will always take the same amount of time, regardless of the data set
- Straight line graph with no gradient
3
Q
What is O(n) - Linear?
A
- The operation time will increase proportionally as the data set increases
- Straight line graph with any gradient -O(3n)- but is always simplified to O(n)
4
Q
What is O(n^2) - Polynomial?
A
- The operation complexity is the square of the size of the data set
- Right side of a quadratic graph
5
Q
What is O(2^n) - exponential?
A
- The operation complexity doubles with each item of data added
- Right side of an exponential graph
6
Q
What is O(log n ) - Logarithmic?
A
- The operation complexity grows very slowly as the data set increases
- Always in base 2
- Graph increases then plateaus
7
Q
What is O(n!) - Factorial?
A
- The operation complexity grows very quickly as the data set increases
- e.g. brute force password cracking
- Graph increases at a steep gradient