AlgorithmsNon-Lecture K: Approximation AlgorithmsLe mieux est l’ennemi du bien. [The best is the enemy of the good.]— Voltaire,La Bégueule(1772)Who shall forbid a wise skepticism, seeing that there is no practical questionon which any thing more than an approximate solution can be had?— Ralph Waldo Emerson,Representative Men(1850)Now, distrust of corporations threatens our still-tentative economic recovery;it turns out greed is bad, after all.— Paul Krugman, “Greed is Bad”,The New York Times, June 4, 2002.KApproximation AlgorithmsK.1Load BalancingOn the future smash hit reality-TV game showGrunt Work, scheduled to air Thursday nights at 3am(2am Central) on ESPNπ, the contestants are given a series of utterly pointless tasks to perform. Eachtask has a predetermined time limit; for example, “Sharpen this pencil for 17 seconds”, or “Pour pig’sblood on your head and sing The Star-Spangled Banner for two minutes”, or “Listen to this 75-minutealgorithms lecture”. The directors of the show want you to assign each task to one of the contestants,so that the last task is completed as early as possible. When your predecessor correctly informed thedirectors that their problem is NP-hard, he was immediately fired. “Time is money!” they screamed athim. “We don’t need perfection. Wake up, dude, this istelevision!”Less facetiously, suppose we have a set ofnjobs, which we want to assign tommachines. We aregiven an arrayT[1..n]of non-negative numbers, whereT[j]is the running time of jobj. We candescribe anassignmentby an arrayA[1..n], whereA[j] =imeans that jobjis assigned to machinei.Themakespanof an assignment is the maximum time that any machine is busy:makespan(A) =maxiXA[j]=iT[j]Theload balancingproblem is to compute the assignment with the smallest possible makespan.It’s not hard to prove that the load balancing problem is NP-hard by reduction from PARTITION: ThearrayT[1..n]can be evenly partitioned if and only if there is an assignment to two machines withmakespan exactly∑iT[i]/2. A slightly more complicated reduction from 3PARTITIONimplies that theload balancing problem isstronglyNP-hard. If we really need the optimal solution, there is a dynamicprogramming algorithm that runs in timeO(nMm), whereMis the minimum makespan, but that’s justhorrible.There is a fairly natural and efficient greedy heuristic for load balancing: consider the jobs one at atime, and assign each job to the machine with the earliest finishing time.GREEDYLOADBALANCE(T[1..n],m):fori←1 tomTotal[i]←0forj←1 tonmin←1fori←2 tonifTotal[i]<Total[min]min←iA[j]←minTotal[min]←Total[min] +T[j]returnA[1..m]1

This preview has intentionally blurred sections.
Sign up to view the full version.

What students are saying

As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran
Temple University Fox School of Business ‘17, Course Hero Intern

I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana
University of Pennsylvania ‘17, Course Hero Intern

The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.