22.01.2014 Views

IEOR 269, Spring 2010 Integer Programming and Combinatorial ...

IEOR 269, Spring 2010 Integer Programming and Combinatorial ...

IEOR 269, Spring 2010 Integer Programming and Combinatorial ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>IEOR</strong><strong>269</strong> notes, Prof. Hochbaum, <strong>2010</strong> 9<br />

7 Complexity of algorithms<br />

It is meaningless to use an algorithm that is “inefficient” (the concept of efficiency will be defined<br />

precisely later). The example in he h<strong>and</strong>out of “Reminiscences <strong>and</strong> Gary & Johnson” shows that<br />

an inefficient algorithm may not result in a solution in a reasonable time, even if it is correct.<br />

Therefore, the complexity of algorithms is an important issue in optimization.<br />

We start by defining polynomial functions.<br />

Definition 7.1. A function p(n) is a polynomial function of n if p(n) = ∑ k<br />

i=0 a in i for some<br />

constants a 0 , a 1 , ..., <strong>and</strong> a k .<br />

The complexity of an algorithm is determined by the number of operations it requires to solve the<br />

problem. Operations that should be counted includes addition, subtraction, multiplication, division,<br />

comparison, <strong>and</strong> rounding. While counting operations is addressed in most of the fundamental<br />

algorithm courses, another equally important issue concerning the length of the problem input will<br />

be discussed below.<br />

We illustrate the concept of input length with the following examples.<br />

7.1 Finding the maximum element<br />

The problem is to find the maximum element in the set of integers {a 1 , ..., a n }. An algorithm for<br />

this problem is<br />

i = 1, a max = a 1<br />

until i = n<br />

i ← i + 1<br />

a max ← max{a i , a max } 2<br />

end<br />

The input of this problem includes the numbers n, a 1 , a 2 , ..., <strong>and</strong> a n . Since we need 1+⌈log 2 x⌉<br />

bits to represent a number x in the binary representation used by computers, the size of the input<br />

is<br />

n∑<br />

1 + ⌈log 2 n⌉ + 1 + ⌈log 2 a 1 ⌉ + · · · + 1 + ⌈log 2 a n ⌉ ≥ n + ⌈log 2 a i ⌉. (7)<br />

To complete the algorithm, the operations we need is n − 1 comparisons. This number is even<br />

smaller than the input length! Therefore, the complexity of this algorithm is at most linear in the<br />

input size.<br />

7.2 0-1 knapsack<br />

As defined in the first lecture, the problem is to solve<br />

i=1<br />

max<br />

s.t.<br />

∑ n<br />

j=1 u jx j<br />

∑ n<br />

j=1 v jx j ≤ B<br />

x j ∈ {0, 1} ∀j = 1, 2, ..., n,<br />

2 this statement is actually implemented by<br />

if a i ≥ a max<br />

a max ← a i<br />

end

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!