Analysis, Design and comparison Flashcards
What is time complexity?
The amount of time that an algorithm will take to solve a problem
What does the Big-O time complexity show?
The maximum amount of time that an algorithm will take relative to the number of inputs
What is Big-O(1)?
Constant time complexity - Time taken in independent from the number of inputs
What is Big-O(n)?
Linear time complexity - The time taken is directly proportional to the number of inputs
What is Big-O(n^k)?
Polynomial time complexity - The time taken is directly proportional to the number of inputs to the power k
What is Big-O(2^n)?
Exponential time complexity - The time taken doubles with every additional input
What is Big-O(log(n))?
Logarithmic time complexity - The time taken increases at a falling rate
Order the time complexities from best to worst
- O(1)
- O(log(n))
-O(n)
-O(n log(n)) - O(n^2) / O(2^n)
What is space complexity?
The amount of space that an algorithm requires to solve a particular problem
What is an algorithm?
A series of steps to solve a problem
How can space complexity be reduced?
The algorithm completes all operations on the original piece of data
How can time complexity be reduced?
The algorithm completes operations on as few number of items as possible