Graphs and Network Flows IE411: Dr. Ted Ralphs
Graphs and Network Flows IE411: Dr. Ted Ralphs
IE411 Lecture 3
Algorithms
algorithm1 1. any systematic method of solving a certain kind of problem 2. a predetermined set of instructions for solving a specic problem in a limited number of steps The concept of an algorithm is not new but formal study of eciency is relatively new.
IE411 Lecture 3
IE411 Lecture 3
IE411 Lecture 3
IE411 Lecture 3
What do We Measure?
Three methods of analysis: Empirical analysis Try to determine how algorithms behave in practice on real computational platforms under load in real-world conditions. Average-case analysis Try to determine the expected running time an algorithm will take analytically. Worst-case analysis Provide an upper bound on the running time of an algorithm for any instance in a given set.
IE411 Lecture 3
Average-Case
Worst-Case
IE411 Lecture 3
IE411 Lecture 3
IE411 Lecture 3
IE411 Lecture 3
10
IE411 Lecture 3
11
Elementary Operations
Elementary operations are very loosely dened to be additions, subtractions, multiplications, comparisons, etc. In most cases, we will assume that each of these can be performed in constant time. Again, this is a good assumption as long as the size of the numbers remains small as the calculation progresses. Generally we will want to ensure that the numbers can be encoded in a size polynomial in the size of the input. This justies our assumption about constant time operations. In some cases, we may have to be very careful about checking this assumption.
IE411 Lecture 3
12
Asymptotic Analysis
So far, we have determined that our measure of running time will be a function of instance size (a positive integer). Determining the exact function is still problematic at best. We will only really be interested in approximately how quickly the function grows in the limit. To determine this, we will use asymptotic analysis. Order relations f (n) O(g(n)) c R+, n0 Z+ s.t. f (n) cg(n) n n0. In this case, we say f is order g or f is big O of g. Using this relation, we can divide functions into classes that are all of the same order.
IE411 Lecture 3
13
Example
for i = 1 p do for j = 1 q do cij = aij + bij How many elementary operations?
IE411 Lecture 3
14
Order Relations
For polynomials, the order relation from the previous slide can be used to divide the set of functions into equivalence classes. We will only be concerned with what equivalence class the function belongs to. Note that class membership is invariant under multiplication by scalars and addition of low-order terms. For polynomials, the class is determined by the largest exponent on any of the variables. For example, all functions of the form f (n) = an2 + bn + c are (n2).
IE411 Lecture 3
15
IE411 Lecture 3
16
IE411 Lecture 3
17
IE411 Lecture 3
18
IE411 Lecture 3
19
IE411 Lecture 3
20