Complexity Flashcards

1
Q

Define an algorithm

A

A computational process that is guaranteed to terminate and return a result for all legal inputs

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

What is a monte carlo algorithm?

A

An algorithm that uses random sampling to get a non random answer

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

What are the four core categories that can be used to distinguish algorithms?

A

Control
Finiteness
Pre conditions
Determinism

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

What is memoisaiton?

A

Optimization technique used to speed up algorithms by storing results of expensive function calls

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

What is the trade off that lies at the heart of complexity?

A

Space versus Speed

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

What are heuristics?

A

A technique designed for approximating a solution when classic methods fail or are too slow

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

Describe the heuristic for finding a median

A

Pick the first three numbers off the list

Sort them, and return the middle one

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

What are the three cases for running time?

A

Worst case
Best case
Average case

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

What does asymptotic mean?

A

As n tends towards infinity

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

What is the best case for sorting?

A

Happens when the list is already sorted

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

What is the worst case for sorting?

A

When the list is perfectly reverse sorted

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

Describe the O notation

A

Captures the most dominant term

Typically a function of n

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

What does the O notation do?

A

Bounds the expression describing the time complexity

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

How can we simplify the function f(n)

A
  • Discard all the terms except the one that grows fastest

- Discard any constant terms

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

What is the problem size for a FSA?

A

Length of the input stream

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

What are pathological cases?

A

Situations for which an algorithm is sub optimal, traps the algorithm falls into

17
Q

What is the pathological case for insertion sort?

A

Reverse sorted list

18
Q

What are the possible solutions to pathological cases?

A

Ignore then
Detect
Use or design a different algorithm

19
Q

What is an inplace algorithm?

A

An algorithm that does not require any extra space and it is able to produce output in the same memory that contains the data by transforming the input in place