SD08 - Complexity 2 Flashcards
What is the ‘Big O’ notation?
A representation of the asymptotic time complexity of an algorithm.
It captures the most dominant term of the complexity function, typically a function of n
What is the complexity of this function?
f(n) = 6n^3 + 4n^2 - 4n + 6
O(n^3)
What is the complexity of recognising a string using a finite-state automaton?
O(n)
Which of these complexities is largest?
O(n)
O(n log n)
O(log n)
O(n log n)
What is the ideal complexity?
O(1)
Not possible for most problems though
Does an algorithm of O(log n) always perform faster than an O(n) algorithm?
No, as the functions have been simplified. They only describe the algorithms behaviours as n gets suitably large.
What is a pathological case for an algorithm?
A situation where the algorithm performs much worse than on average
e.g. An insertion sort with a reverse sorted list. It does twice as much work as on average