Efficiency of Algorithms - Part 1 Flashcards

1
Q

What do we need to do to analyze the efficiency of two algorithms?

give 2 examples

A

count some significant measure of what affects the performance.

  1. significant operations
  2. number of lines of code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

consider the ____ when counting the number of times a line of code is executed

A

worst case

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

what defines the efficiency of the algorithm?

A

the function that comes from adding up all the execution count values for each line

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

What do we need to know to compare the efficiency of two algorithms?

A

whether one function is greater than another

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

What does it mean for one function to be greater than another?

A

it grows faster

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

Why is there no natural total ordering of functions?

A

they are defined on so many values

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

give an example of a partial ordering of functions

A

f is less than or equal to g if f of x is less than or equal to g of x everywhere.

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

what is wrong with some partial orders?

A

many functions aren’t comparable throughout every possible x value

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

What is Big-O’s advantage?

A

introduces 2 constants that make more functions comparable

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

What are the two constants of Big-O notation? describe them.

A

C, a multiplier, makes the constant factors matter less

n_0, a beginning point, so we only care about things happening from this point onward

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

How do we define the ordering of Big-O

A

f is less than or equal to g if Big-O of f, which is a set, is a subset of Big-O of g

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

What are the 3 requirements for a partial order?

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

what does reflexive mean?

A

everything is less than or equal to itself

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

what does anti-symmetric mean?

A

if one element is less than another and vice versa, the two have to be equal

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

what is the transitive property?

A

if x is less than or equal to y and y is less than or equal to z then x has to be less than or equal to z

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

What is the difference between a partial order and a total order?

A

in a total order, all pairs are comparable. In a partial order, some are not.

17
Q

explain the partial order of divisibility

A

one value is less than another is the first divides the second