Algorithm concepts Flashcards

1
Q

Uniform cost model

A

All machine operations have a constant cost, whatever the values

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

Time complexity

A

T(N) = aN + b

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

Asymptotic notation

A

aN + b = O(N) T(N) = O(N) highest order term determines the bound

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

Definition “Big O” (Upper Bound)

A

A function f(N) has an asymptotic upper bound given by the function g(N), written f(N) = O(g(N)), if and only if there are positive real numbers c and n0 such that 0 ≤ f(N) ≤ c g(N) for all N ≥ n0

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

Definition “Big Omega” (Lower Bound)

A

A function f(N) has an asymptotic lower bound given by the function g(N), written f(N) = Ω(g(N)), if and only if there are positive real numbers c and n0 such that 0 ≤ c g(N) ≤ f(N) for all N ≥ n0

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

Definition “Big Theta” (Tight Bound)

A

A function f(N) has an asymptotic tight bound given by the function g(N), written f(N) = Θ(g(N)), if and only if there are positive real numbers c1, c2, and n0 such that 0 ≤ c1 g(N) ≤ f(N) ≤ c2 g(N) for all N ≥ n0

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

Space complexity

A

The space complexity of an algorithm is the total amount of memory used, including that used by input parameters, as a function of the size of the input

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

Auxiliary Space

A

The auxiliary space is the amount of extra memory required, not including input parameters, as a function of the size of the input.

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

Polynomial

A

p(N) = a0 + a1N + a2N^2 + … + adN^d in which ad ≠ 0 asymptotically positive iff ad > 0

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

Exponential

A

include a term of the form a^N

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

Divide and Conquer

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

Recursion Tree

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

Master Method

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

Master Method pt 2

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

Master Method pt 3 (extra check)

A

Regularity condition

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

Master method excluded cases

A

The master method does not apply to these recurrences

T(N) = NT(N/2) + N
T(N) = 0.5T(N/2) + 4N
T(N) = 4T(N/8) − N2

T (N ) = 2T (N /2) + N / log N

The (mostly straightfoward) reasons are

the number of subproblems in the first two

negative divide and combine time (third example)

negative value of k (fourth example)

17
Q

Heap

A
18
Q

Binary search tree add code

A
19
Q

Hash function

A

common to implement hash function in two steps

either stage can cause collisions

20
Q

Adjacency lists

A
21
Q

Code for Kruskal’s

A
22
Q

Prim’s code

A
23
Q

Bellman-Ford

A
24
Q

Relax

A
25
Q

Bellman-Ford to detect negative weight cycle

A
26
Q

Bellman-Ford

A
27
Q

Dijkstra

A
28
Q

Dijkstra’s correctness

A
29
Q

Dijkstra’s correctness pt 2

A