What
- Provides an abstraction (“rough” measure) of resources used with respect to problem size
- Resources used can be Time or Space
Important Facts for (e.g. )
- Constants do not matter
- The constants , and can be adjusted to compensate for constants
- Minor terms do not matter
- E.g. if , then we can say , because we are analysing asymptotic behaviour of the functions
- For certain problems, can be calculated using Master Theorem
When to use , and
Big theta Is the most strict analysis. Often, for more complex functions, it is difficult to define big theta. This is when we use big O (and occasionally big omega).
Types of Analyses
Common values of
Exam Question Examples
function f(n) {
return n < 1 ? 1 : f(n - 5) + f(n - 5);
}function f(n) {
if (n < 1) {
return 1;
} else {
enum_list(1, n); // Theta(n)
f(n - 5);
}
}