Time Complexity Flashcards
1
Q
Time stays same no matter how many elements
eg: Array[x] / array.push
A
(1) Constant complexity O(1)
2
Q
Time increases as number of elements increases
eg: for loop
A
(3) Linear complexity O(n)
3
Q
Time increases exponentially as elements increase
eg: nested for loops
A
(5) Quadratic complexity O(n^2)
4
Q
Time complexity is reduced in some way by limiting or dividing the number of elements accessed
(eg: for loop with divide by 2 / binary search)
A
(2) Logarithmic complexity O(log n)
5
Q
Time complexity increases like an exponential loop but is limited by dividing the number of elements
(eg: divide and conquer on an n^2 algorithm )
A
(4) nLogN O(n log n)