Lecture 1 - Time Complexity Revision Flashcards

1
Q

What is time complexity?

A

A function of input size, denoting how long the algorithm will run for. We typically look at the worst-case of an algorithm.

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

Why do we use the worst-case of an algorithm?

A

Since worst-case provides a gurantee on algorithm’s performance.

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

What is asymptotic behaviour ?

A

Behaviour of never-ending input. It is a mathematical concept.

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

What are the Big-Oh functions?

A

f(n) = O(g(n)) and f(n) <= cg(n)

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

What does the Big-Oh function f(n) = O(g(n)) mean?

A

That the function f grows no faster than function g.

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

In Big-Oh which function is well know ?

A

g(n) e.g. O(n)

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

In Big-Oh which function is not known precisely?

A

f(n)

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

What do we need to remember when working with Big-Oh?

A

To always bind tightest, even if greater functions are valid. E.g. if O(n^2) is valid, then so is O(n^3) and so on, but we would still use O(n^2), since it binds the tightest.

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

What is Big-Oh ?

A

Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity.

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

What can x = logaN be (where a has a power)?

A

n = a^x

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

Log properties to remember?

A
  • log mn = log m + log n
  • log m/n = log m - log n
  • log n^c = c log n
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Are logs of different bases related, how so ?

A

Yes, these are related by a constant factor. This is done by taking the same log of both sides and simplifying.

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

Solve x = logaN, by taking logs of both sides.

A

x = logaN
logbN= logb A^x
logbN = X log A
since x = logaN we get logbN = logaN * logbA
c = logbA is a consant , since both b and a are constants
logbN = clogaN
this gives O(logn)

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

What is polynomial time?

A

O(n^c)

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

What is exponential time?

A

O(c^n)

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

Is exponential useful?

A

No it is potentially useless.