algorithms and complexity Flashcards

1
Q

what is an algorithm

A

set of computational steps that transforms an input into an output

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

why do we study algorithms

A

to check performance correctness robustness and simplicity

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

space complexity

A

the amount of memory required for an algorithm to run to completion

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

fixed part

A

the size required to store certain variables that are independent to the size of the problem

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

variable part

A

the space needed by variables with their size dependent on the size of the problem

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

what is the experimental approach of calculating the run time

A

you can implement the program and input different values to accurately measure the running time them plot a graph from your findings

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

what are some limitations to the experimental approach

A

the algorithm must be implemented which can take a long time and can be difficult
to compare two algorithms the same hardware and software must be used which may be difficult

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

what is an alternative to the experimental approach

A

operation counting

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

what does sigma notation do

A

expresses sums where each term is in the same form

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

what is the sigma formation for a for loop

A

b
∑ 1 = b - a + 1
i = a

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

how do you calculate the average case

A

sum up all the inputs and divide by the total number of inputs

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

what is big o notation used for

A

calculating the growth of functions

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

what is the order of function growth

A

constant - log n - n^c (o < c < 1) - n - nlog n - n^2 - n^3 - 2^n - 3^n - n!

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

what is the formal definition of big o

A

f(n) = O(g(n)) means there are positive constants c and k, such that 0 ≤ f(n) ≤ cg(n) for all n ≥ k
big o establishes an upper bound for the growth of functions when numbers start to get very large
upper bound

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

what is the formal definition for big omega (Ω)

A

provides a lower bound
f(n) is said to be Ω(g (n)) if there exists positive constant C and (n0) such that 0 <= Cg(n) <= f(n) for all n >= n0

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

what is the formal definiton for big theta(Θ)

A

f(n) is said to be Θ(g(n)) if f(n) is O(g(n)) and f(n) is Ω(g(n))
0 <= C2g(n) <= f(n) <= C1g(n) for n >= n0
average bound

17
Q

how do you find the time complexity of a recursive algorithm

A

you identify two properties of t(n); base case (1) and n > 1
then use either back substitution a recursion tree or master theorem to solve the recurrence relation

18
Q

why can we not rely on faster computers to speed up an inefficient algorithm

A

the less efficient the algorithm is the less quickly the computer can reduce the problem size

19
Q

np

A

non deterministic polynomial time; decision problems that can be checked in polynomial time | a set of all decision problems solvable in polynomial time with a non-deterministic algorithm

20
Q

p vs np

A

if its easy to check in polynomial time then would it be easy to solve

21
Q

what can we do when we have intractable problems

A

use heuristics; a good enough solution
solve the problem approximately
us the exponential time algorithm anyways

22
Q

what is the factoring problem

A

when given the answer what two prime numbers can be multiplied together to make it

23
Q

decision problems

A

with yes or no answers

24
Q

decidable

A

a decision problem that can be solved with an algorithm

25
Q

optimisation problems

A

require a value to be minimised or maximised

26
Q

how do we convert an optimisation problem into a decision problem

A

by asking is there a solution that has a value lower or higher than the given value

27
Q

clique

A

a complete subgraph of the graph; all vertices and nodes are are connected to each other

28
Q

non-determinism

A

the idea of trying everything and if any of them work they return yes; evaluates all branches of a decision trees simultaneously

29
Q

certifier

A

given an input (problem instance) and a candidate solution (the certifier) checks whether the candidate solution satisfies the problems requirements
checks if its correct within polynomial time

30
Q

what is an np complete problem

A

it is in np
it is as hard as any np problem
decision problems that contains he hardest problems in np

31
Q

how can we show that one problem is as hard as another

A

using polynomial time reductions

32
Q

what is a reduction

A

a method of solving a problem using another

33
Q

how do you carry out a polynomial time reduction

A

define the source problem and the target problem
design a function that transforms an instance of a into b that is computable in polynomial time and ensure its correct (yes for a is a yes for b)
prove the polynomial time complexity
combine the algorithm to solve function b with the reduction algorithm

34
Q

𝑌 ≤p 𝑋

A

y is no harder than x

35
Q

np hard

A

problems that are at least as hard as the hardest problems in np; do not have to be elements of np

36
Q

how do we show np completeness

A

show that b is in np
choose an np complete problem and prove that x is no harder than b (𝑋 ≤p 𝐵) (reducing x to b in polynomial time)

37
Q
A