SD08 - Complexity 2 Flashcards

1
Q

What is the ‘Big O’ notation?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the complexity of this function?

f(n) = 6n^3 + 4n^2 - 4n + 6

A

O(n^3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the complexity of recognising a string using a finite-state automaton?

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of these complexities is largest?
O(n)
O(n log n)
O(log n)

A

O(n log n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the ideal complexity?

A

O(1)

Not possible for most problems though

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Does an algorithm of O(log n) always perform faster than an O(n) algorithm?

A

No, as the functions have been simplified. They only describe the algorithms behaviours as n gets suitably large.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a pathological case for an algorithm?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly