Comp & Prgm with Python - Ch 12 Flashcards
Opitimization
Requires two parts
Optimization function & constraints.
Opt function = compute desired outcome
Constraints = conditional limits, can be empty
Greedy Algo
Selects the first element that meets criteria, repeat
Often a practical approach
Provides an approximate answer, not an optimal
0/1 Knapsack problem
Theoretically always O(n*n^2) with brute force algo
Because it requires computing a power set and that is always n*n^2
Optimize a slow process
Include checks that stop computation once results are outside of criteria
Vectors
Dynamic arrays from c++
Characteristics
Low memory usage
Random access to elements
Graphs
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
On choosing a subclass or super class
Substituting an instance of a subclass into the super class should result in zero errors