Comp & Prgm with Python - Ch 12 Flashcards

1
Q

Opitimization

A

Requires two parts
Optimization function & constraints.
Opt function = compute desired outcome
Constraints = conditional limits, can be empty

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

Greedy Algo

A

Selects the first element that meets criteria, repeat

Often a practical approach

Provides an approximate answer, not an optimal

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

0/1 Knapsack problem

A

Theoretically always O(n*n^2) with brute force algo

Because it requires computing a power set and that is always n*n^2

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

Optimize a slow process

A

Include checks that stop computation once results are outside of criteria

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

Vectors

A

Dynamic arrays from c++

Characteristics
Low memory usage
Random access to elements

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

Graphs

A

Consists of nodes(vertices) and edges(arcs)

If edges are unidirectional it is a directed graph or digraph

If edges are weighted it is a weighted graph

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

On choosing a subclass or super class

A

Substituting an instance of a subclass into the super class should result in zero errors

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