15 Pages

00-intro

Course: CS 473, Fall 2011
School: University of Illinois,...
Rating:
 
 
 
 
 

Word Count: 7448

Document Preview

0: Algorithms Lecture Introduction [F10] We should explain, before proceeding, that it is not our object to consider this program with reference to the actual arrangement of the data on the Variables of the engine, but simply as an abstract question of the nature and number of the operations required to be perfomed during its complete solution. -- Ada Augusta Byron King, Countess of Lovelace, translator's notes...

Register Now

Unformatted Document Excerpt

Coursehero >> Illinois >> University of Illinois, Urbana Champaign >> CS 473

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
0: Algorithms Lecture Introduction [F10] We should explain, before proceeding, that it is not our object to consider this program with reference to the actual arrangement of the data on the Variables of the engine, but simply as an abstract question of the nature and number of the operations required to be perfomed during its complete solution. -- Ada Augusta Byron King, Countess of Lovelace, translator's notes for Luigi F. Menabrea, "Sketch of the Analytical Engine invented by Charles Babbage, Esq." (1843) You are right to demand that an artist engage his work consciously, but you confuse two different things: solving the problem and correctly posing the question. -- Anton Chekhov, in a letter to A. S. Suvorin (October 27, 1888) The more we reduce ourselves to machines in the lower things, the more force we shall set free to use in the higher. -- Anna C. Brackett, The Technique of Rest (1892) The moment a man begins to talk about technique that's proof that he is fresh out of ideas. -- Raymond Chandler 0 0.1 Introduction What is an algorithm? An algorithm is an explicit, precise, unambiguous, mechanically-executable sequence of elementary instructions. For example, here is an algorithm for singing that annoying song `99 Bottles of Beer on the Wall', for arbitrary values of 99: B OTTLESOFBEER(n): For i n down to 1 Sing "i bottles of beer on the wall, i bottles of beer," Sing "Take one down, pass it around, i - 1 bottles of beer on the wall." Sing "No bottles of beer on the wall, no bottles of beer," Sing "Go to the store, buy some more, n bottles of beer on the wall." The word `algorithm' does not derive, as algorithmophobic classicists might guess, from the Greek root algos ( ), meaning `pain'. Rather, it is a corruption of the name of the 9th century Persian mathematician Ab 'Abd Allh Muhammad ibn M s al-Khwrizm 1 Al-Khwrizm is perhaps best u a u a a i. a i . 2 known as the writer of the treatise Al-Kitb al-mukhtasar f isb al-abr wa'l-muqbala , from which the a ih a g a . modern word algebra derives. In another treatise, al-Khwrizm popularized the modern decimal system a i for writing and manipulating numbers--in particular, the use of a small circle or . ifr to represent a missing s quantity--which had originated in India several centuries earlier. This system later became known in Europe as algorism. Thanks to the efforts of the medieval Italian mathematician Leonardo of Pisa, better known as Fibonacci, algorism began to replace the abacus as the preferred system of commercial calculation3 in Europe in the late 12th century, although cyphers became truly ubiquitous in Western Europe only after the French revolution 600 years later. The more modern word algorithm is a false 1 `Mohammad, father of Adbdulla, son of Moses, the Kwrizmian'. Kwrizm is an ancient city, now called Khiva, in the a a Khorezm Province of Uzbekistan. 2 `The Compendious Book on Calculation by Completion and Balancing'. 3 from the Latin word calculus, meaning literally `small rock', referring to the stones on a counting board, or abacus Copyright 2010 Jeff Erickson. Released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License (http://creativecommons.org/licenses/by-nc-sa/3.0/). Free distribution is strongly encouraged; commercial distribution is expressly forbidden. See http://www.cs.uiuc.edu/~jeffe/teaching/algorithms/ for the most recent revision. 1 Algorithms Lecture 0: Introduction [F10] cognate with the Greek word arithmos ( ), meaning `number' (and perhaps the aforementioned ). Thus, until very recently, the word algorithm referred exclusively to pencil-and-paper methods for numerical calculations. People trained in the reliable execution of these methods were called--you guessed it--computers. 0.2 A Few Simple Examples Multiplication by compass and straightedge Although they have only been an object of formal study for a few decades, algorithms have been with us since the dawn of civilization, for centuries before Al-Khwrizm and Fibonacci popularized the cypher. a i Here is an algorithm, popularized (but almost certainly not discovered) by Euclid about 2500 years ago, for multiplying or dividing numbers using a ruler and compass. The Greek geometers represented numbers using line segments of the appropriate length. In the pseudo-code below, CIRCLE(p, q) represents the circle centered at a point p and passing through another point q. Hopefully the other instructions are obvious.4 Z Construct the line perpendicular to and passing through P . RIGHTANGLE( , P): Choose a point A A, B INTERSECT(CIRCLE(P, A), ) C, D INTERSECT(CIRCLE(A, B), CIRCLE(B, A)) return LINE(C, D) Construct a point Z such that |AZ| = |AC||AD|/|AB|. MULTIPLYORDIVIDE(A, B, C, D): RIGHTANGLE(LINE(A, C), A) E INTERSECT(CIRCLE(A, B), ) F INTERSECT(CIRCLE(A, D), ) RIGHTANGLE(LINE(E, C), F ) RIGHTANGLE(, F ) return INTERSECT(, LINE(A, C)) C D B F A E Multiplying or dividing using a compass and straightedge. This algorithm breaks down the difficult task of multiplication into a series of simple primitive operations: drawing a line between two points, drawing a circle with a given center and boundary point, and so on. These primitive steps are quite non-trivial to execute on a modern digital computer, but this algorithm wasn't designed for a digital computer; it was designed for the Platonic Ideal Classical Greek Mathematician, wielding the Platonic Ideal Compass and the Platonic Ideal Straightedge. In this example, Euclid first defines a new primitive operation, constructing a right angle, by (as modern programmers would put it) writing a subroutine. 4 Euclid and his students almost certainly drew their constructions on an , a table covered in dust or sand (or perhaps very small rocks). Over the next several centuries, the Greek abax evolved into the medieval European abacus. 2 Algorithms Multiplication by duplation and mediation Lecture 0: Introduction [F10] Here is an even older algorithm for multiplying large numbers, sometimes called (Russian) peasant multiplication. A variant of this method was copied into the Rhind papyrus by the Egyptian scribe Ahmes around 1650 BC, from a document he claimed was (then) about 350 years old. This was the most common method of calculation by Europeans before Fibonacci's introduction of Arabic numerals; it was still taught in elementary schools in Eastern Europe in the late 20th century. This algorithm was also commonly used by early digital computers that did not implement integer multiplication directly in hardware. PEASANTMULTIPLY(x, y): prod 0 while x > 0 if x is odd prod prod + y x x/2 y y+y return p x 123 61 30 15 7 3 1 y +456 +912 1824 +3648 +7296 +14592 +29184 prod 0 = 456 = 1368 = 5016 = 12312 = 26904 = 56088 The peasant multiplication algorithm breaks the difficult task of general multiplication into four simpler operations: (1) determining parity (even or odd), (2) addition, (3) duplation (doubling a number), and (4) mediation (halving a number, rounding down).5 Of course a full specification of this algorithm requires describing how to perform those four `primitive' operations. Peasant multiplication requires (a constant factor!) more paperwork to execute by hand, but the necessary operations are easier (for humans) to remember than the 10 10 multiplication table required by the American grade school algorithm.6 The correctness of peasant multiplication follows from the following recursive identity, which holds for any non-negative integers x and y: if x = 0 0 xy= x/2 ( y + y) if x is even x/2 ( y + y) + y if x is odd Congressional Apportionment Here is another good example of an algorithm that comes from outside the world of computing. Article I, Section 2 of the United States Constitution requires that Representatives and direct Taxes shall be apportioned among the several States which may be included within this Union, according to their respective Numbers. . . . The Number of Representatives shall not exceed one for every thirty Thousand, but each State shall have at Least one Representative. . . . Since there are a limited number of seats available in the House of Representatives, exact proportional representation is impossible without either shared or fractional representatives, neither of which are The version of this algorithm actually used in ancient Egypt does not use mediation or parity, but it does use comparisons. To avoid halving, the algorithm pre-computes two tables by repeated doubling: one containing all the powers of 2 not exceeding x, the other containing the same powers of 2 multiplied by y. The powers of 2 that sum to x are then found by greedy subtraction, and the corresponding entries in the other table are added together to form the product. 6 American school kids learn a variant of the lattice multiplication algorithm developed by Indian mathematicians and described by Fibonacci in Liber Abaci. The two algorithms are equivalent if the input numbers are represented in binary. 5 3 Algorithms Lecture 0: Introduction [F10] legal. As a result, several different apportionment algorithms have been proposed and used to round the fractional solution fairly. The algorithm actually used today, called the Huntington-Hill method or the method of equal proportions, was first suggested by Census Bureau statistician Joseph Hill in 1911, refined by Harvard mathematician Edward Huntington in 1920, adopted into Federal law (2 U.S.C. 2a and 2b) in 1941, and survived a Supreme Court challenge in 1992.7 The input array Pop[1 .. n] stores the populations of the n states, and R is the total number of representatives. Currently, n = 50 and R = 435. The output array Rep[1 .. n] stores the number of representatives assigned to each state. APPORTIONCONGRESS(Pop[1 .. n], R): PQ NEWPRIORITYQUEUE for i 1 to n Rep[i] 1 INSERT PQ, i, Pop[i]/ 2 RR-1 while R > 0 s EXTRACTMAX(PQ) Rep[s] Rep[s] + 1 INSERT PQ, s, Pop[s] RR-1 return Rep[1 .. n] Rep[s] (Rep[s] + 1) This pseudocode description assumes that you know how to implement a priority queue that supports the operations NEWPRIORITYQUEUE, INSERT, and EXTRACTMAX. (The actual law doesn't assume that, of course.) The output of the algorithm, and therefore its correctness, does not depend at all on how the priority queue is implemented. The Census Bureau uses an unsorted array, stored in a column of an Excel spreadsheet; you should have learned a more efficient solution in your undergraduate data structures class. A bad example Consider "Martin's algorithm":8 BECOMEAMILLIONAIREANDNEVERPAYTAXES: Get a million dollars. Don't pay taxes. If you get caught, Say "I forgot." Pretty simple, except for that first step; it's a doozy. A group of billionaire CEOs might consider this an algorithm, since for them the first step is both unambiguous and trivial, but for the rest of us poor slobs, Martin's procedure is too vague to be considered an actual algorithm. On the other hand, this is a perfect example of a reduction--it reduces the problem of being a millionaire and never paying taxes to the `easier' problem of acquiring a million dollars. We'll see reductions over and over again in this class. Overruling an earlier ruling by a federal district court, the Supreme Court unanimously held that any apportionment method adopted in good faith by Congress is constitutional (United States Department of Commerce v. Montana). The current congressional apportionment algorithm is described in gruesome detail at the U.S. Census Department web site http://www.census.gov/population/www/censusdata/apportionment/computing.html. A good history of the apportionment problem can be found at http://www.thirty-thousand.org/pages/Apportionment.htm. A report by the Congressional Research Service describing various apportionment methods is available at http://www.rules.house.gov/archives/RL31074.pdf. 8 S. Martin, "You Can Be A Millionaire", Saturday Night Live, January 21, 1978. Appears on Comedy Is Not Pretty, Warner Bros. Records, 1979. 7 4 Algorithms Lecture 0: Introduction [F10] As hundreds of businessmen and politicians have demonstrated, if you know how to solve the easier problem, a reduction tells you how to solve the harder one. Martin's algorithm, like many of our previous examples, is not the kind of algorithm that computer scientists are used to thinking about, because it is phrased in terms of operations that are difficult for computers to perform. In this class, we'll focus (almost!) exclusively on algorithms that can be reasonably implemented on a computer. In other words, each step in the algorithm must be something that either is directly supported by common programming languages (such as arithmetic, assignments, loops, or recursion) or is something that you've already learned how to do in an earlier class (like sorting, binary search, or depth first search). 0.3 Writing down algorithms Computer programs are concrete representations of algorithms, but algorithms are not programs; they should not be described in a particular programming language. The whole point of this course is to develop computational techniques that can be used in any programming language. The idiosyncratic syntactic details of C, C++, C#, Java, Python, Ruby, Erlang, Haskell, OcaML, Scheme, Visual Basic, Smalltalk, Javascript, Processing, Squeak, Forth, TEX, Fortran, COBOL, Intercal, or Brainfuck are of little or no importance in algorithm design, and focusing on them will only distract you from what's really going on.9 What we really want is closer to what you'd write in the comments of a real program than the code itself. On the other hand, a plain English prose description is usually not a good idea either. Algorithms have a lot of structure--especially conditionals, loops, and recursion--that are far too easily hidden by unstructured prose. Like any natural languags, English is full of ambiguities, subtleties, and shades of meaning, but algorithms must be described as accurately as possible. Finally and more seriously, there is natural tendency to describe repeated operations informally: "Do this first, then do this second, and so on." But as anyone who has taken one of those `What comes next in this sequence?' tests already knows, specifying what happens in the first few iterations of a loop says very little about what happens later iterations. To make the description unambiguous, we must explicitly specify the behavior of every iteration. The best way to write down an algorithm is using pseudocode. Pseudocode uses the structure of formal programming languages and mathematics to break algorithms into primitive steps; but the primitive steps themselves may be written using mathematics, pure English, or an appropriate mixture of the two. Well-written pseudocode reveals the internal structure of the algorithm but hides irrelevant implementation details, making the algorithm much easier to understand, analyze, debug, and implement. The precise syntax of pseudocode is a personal choice, but the overriding goal should be clarity and precision. Ideally, pseudocode should allow any competent programmer to implement the underlying algorithm, quickly and correctly, in their favorite programming language, without understanding why the algorithm works. Here are the guidelines I follow and strongly recommend: This is, of course, a matter of religious conviction. Linguists argue incessantly over the Sapir-Whorf hypothesis, which states (more or less) that people think only in the categories imposed by their languages. According to an extreme formulation of this principle, some concepts in one language simply cannot be understood by speakers of other languages, not just because of technological advancement--How would you translate `jump the shark' or `blog' into Aramaic?--but because of inherent structural differences between languages and cultures. For a more skeptical view, see Steven Pinker's The Language Instinct. There is admittedly some strength to this idea when applied to different programming paradigms. (What's the Y combinator, again? How do templates work? What's an Abstract Factory?) Fortunately, those differences are generally too subtle to have much impact in this class. 9 5 Algorithms Be consistent! Lecture 0: Introduction [F10] Use standard imperative programming keywords (if/then/else, while, for, repeat/until, case, return) and notation (variable value, Array[index], function(argument), bigger > smaller, etc.). Keywords should be standard English words: write `else if' instead of `elif'. Indent everything carefully and consistently; the block structure should be visible from across the room. This rule is especially important for nested loops and conditionals. Don't add unnecessary syntactic sugar like braces or begin/end tags; careful indentation is almost always enough. Use mnemonic algorithm and variable names. Short variable names are good, but readability is more important than concision; except for idioms like loop indices, short but complete words are better than single letters. Absolutely never use pronouns! Use standard mathematical notation for standard mathematical things. For example, write x y instead of x y for multiplication; write x mod y instead of x % y for remainder; write x instead of sqrt(x) for square roots; write a b instead of power(a, b) for exponentiation; and write instead of phi for the golden ratio. Avoid mathematical notation if English is clearer. For example, `Insert a into X ' may be preferable to INSERT(X , a) or X X {a}. Each statement should fit on one line, and each line should contain either exactly one statement or exactly one structuring element (for, while, if). (I sometimes make an exception for short and similar statements like i i + 1; j j - 1; k 0.) Don't use a fixed-width typeface to typeset pseudocode; it's much harder to read than normal typeset text. Similarly, don't typeset keywords like `for' or `while' in a different style; the syntactic sugar is not what you want the reader to look at. On the other hand, I use italics for variables, SMALL CAPS for algorithms and constants, and a different typeface for literal strings and comments. 0.4 Analyzing algorithms It's not enough just to write down an algorithm and say `Behold!' We also need to convince ourselves (and our graders) that the algorithm does what it's supposed to do, and that it does it efficiently. Correctness In some application settings, it is acceptable for programs to behave correctly most of the time, on all `reasonable' inputs. Not in this class; we require algorithms that are correct for all possible inputs. Moreover, we must prove that our algorithms are correct; trusting our instincts, or trying a few test cases, isn't good enough. Sometimes correctness is fairly obvious, especially for algorithms you've seen in earlier courses. On the other hand, `obvious' is all too often a synonym for `wrong'. Many of the algorithms we will discuss in this course will require extra work to prove correct. Correctness proofs almost always involve induction. We like induction. Induction is our friend.10 But before we can formally prove that our algorithm does what we want it to do, we have to formally state what we want it to do! Usually problems are given to us in real-world terms, not with formal mathematical descriptions. It's up to us, the algorithm designers, to restate these problems in terms of mathematical objects that we can prove things about--numbers, arrays, lists, graphs, trees, and so on. 10 If induction is not your friend, you will have a hard time in this course. 6 Algorithms Lecture 0: Introduction [F10] We also need to determine if the problem statement makes any hidden assumptions, and state those assumptions explicitly. (For example, in the song "n Bottles of Beer on the Wall", n is always a positive integer.) Restating the problem formally is not only required for proofs; it is also one of the best ways to really understand what the problems is asking for. The hardest part of answering any question is figuring out the right way to ask it! It is important to remember the distinction between a problem and an algorithm. A problem is a task to perform, like "Compute the square root of x" or "Sort these n numbers" or "Keep n algorithms students awake for t minutes". An algorithm is a set of instructions for accomplishing such a task. The same problem may have hundreds of different algorithms; the same algorithm may solve hundreds of different problems. Running time The most common way of ranking different algorithms for the same problem is by how fast they run. Ideally, we want the fastest possible algorithm for our problem. In many application settings, it is acceptable for programs to run efficiently most of the time, on all `reasonable' inputs. Not in this class; we require algorithms that always run efficiently, even in the worst case. But how do we measure running time? As a specific example, how long does it take to sing the song B OTTLESOFBEER(n)? This is obviously a function of the input value n, but it also depends on how quickly you can sing. Some singers might take ten seconds to sing a verse; others might take twenty. Technology widens the possibilities even further. Dictating the song over a telegraph using Morse code might take a full minute per verse. Downloading an mp3 over the Web might take a tenth of a second per verse. Duplicating the mp3 in a computer's main memory might take only a few microseconds per verse. What's important here is how the singing time changes as n grows. Singing B OTTLESOFBEER(2n) takes about twice as long as singing B OTTLESOFBEER(n), no matter what technology is being used. This is reflected in the asymptotic singing time (n). We can measure time by counting how many times the algorithm executes a certain instruction or reaches a certain milestone in the `code'. For example, we might notice that the word `beer' is sung three times in every verse of B OTTLESOFBEER, so the number of times you sing `beer' is a good indication of the total singing time. For this question, we can give an exact answer: B OTTLESOFBEER(n) uses exactly 3n + 3 beers. There are plenty of other songs that have non-trivial singing time. This one is probably familiar to most English-speakers: NDAYSOFCHRISTMAS(gifts[2 .. n]): for i 1 to n Sing "On the i th day of Christmas, my true love gave to me" for j i down to 2 Sing " j gifts[ j]" if i > 1 Sing "and" Sing "a partridge in a pear tree." The input to NDAYSOFCHRISTMAS is a list of n - 1 gifts. It's quite easy to show that the singing time is n (n2 ); in particular, the singer mentions the name of a gift i=1 i = n(n + 1)/2 times (counting the partridge in the pear tree). It's also easy to see that during the first n days of Christmas, my true love n i gave to me exactly i=1 j=1 j = n(n + 1)(n + 2)/6 = (n3 ) gifts. Other songs that take quadratic time to sing are "Old MacDonald Had a Farm", "There Was an Old Lady Who Swallowed a Fly", "The House that Jack Built", "Hole in the Bottom of the Sea", "Green Grow the Rushes O", "Eh, Cumpari!", "Alouette", Mi "Echad Yode'a", "Chad Gadya", "Minkurinn hnsnakofanum", and "Ist das nicht ein Schnitzelbank?" For further details, consult your nearest preschooler. 7 Algorithms Lecture 0: Introduction [F10] OLDMACDONALD(animals[1 .. n], noise[1 .. n]): for i 1 to n Sing "Old MacDonald had a farm, E I E I O" Sing "And on this farm he had some animals[i], E I E I O" Sing "With a noise[i] noise[i] here, and a noise[i] noise[i] there" Sing "Here a noise[i], there a noise[i], everywhere a noise[i] noise[i]" for j i - 1 down to 1 Sing "noise[ j] noise[ j] here, noise[ j] noise[ j] there" Sing "Here a noise[ j], there a noise[ j], everywhere a noise[ j] noise[ j]" Sing "Old MacDonald had a farm, E I E I O." ALOUETTE(lapart[1 .. n]): Chantez Alouette, gentille alouette, alouette, je te plumerais. pour tout i de 1 n Chantez Je te plumerais lapart[i]. Je te plumerais lapart[i]. pour tout j de i - 1 bas 1 Chantez Et lapart[ j] ! Et lapart[ j] ! Chantez Ooooooo! Chantez Alouette, gentille alluette, alouette, je te plumerais. For a slightly more complicated example, consider the algorithm APPORTIONCONGRESS. Here the running time obviously depends on the implementation of the priority queue operations, but we can certainly bound the running time as O(N + RI + (R - n)E), where N denotes the running time of NEWPRIORITYQUEUE, I denotes the running time of INSERT, and E denotes the running time of EXTRACTMAX. Under the reasonable assumption that R > 2n (on average, each state gets at least two representatives), we can simplify the bound to O(N + R(I + E)). The Census Bureau implements the priority queue using an unsorted array of size n; this implementation gives us N = I = (1) and E = (n), so the overall running time is O(Rn). This is good enough for government work, but we can do better. Implementing the priority queue using a binary heap (or a heap-ordered array) gives us N = (1) and I = R = O(log n), which implies an overall running time of O(R log n). Sometimes we are also interested in other computational resources: space, randomness, page faults, inter-process messages, and so forth. We can use the same techniques to analyze those resources as we use to analyze running time. 0.5 A Longer Example: Stable Matching Every year, thousands of new doctors must obtain internships at hospitals around the United States. During the first half of the 20th century, competition among hospitals for the best doctors led to earlier and earlier offers of internships, sometimes as early as the second year of medical school, along with tighter deadlines for acceptance. In the 1940s, medical schools agreed not to release information until a common date during their students' fourth year. In response, hospitals began demanding faster decisions. By 1950, hospitals would regularly call doctors, offer them internships, and demand immediate responses. Interns were forced to gamble if their third-choice hospital called first--accept and risk losing a better opportunity later, or reject and risk having no position at all.11 Finally, a central clearinghouse for internship assignments, now called the National Resident Matching Program, was established in the early 1950s. Each year, doctors submit a ranked list of all hospitals where they would accept an internship, and each hospital submits a ranked list of doctors they would 11 The academic job market involves similar gambles, at least in computer science. Some departments start making offers in February with two-week decision deadlines; other departments don't even start interviewing until late March; MIT notoriously waits until May, when all its interviews are over, before making any faculty offers. 8 Algorithms Lecture 0: Introduction [F10] accept as interns. The NRMP then computes an assignment of interns to hospitals that satisfies the following stability requirement. For simplicity, let's assume that there are n doctors and n hospitals; each hospital offers exactly one internship; each doctor ranks all hospitals and vice versa; and finally, there are no ties in the doctors' and hospitals' rankings.12 We say that a matching of doctors to hospitals is unstable if there are two doctors and and two hospitals A and B, such that is assigned to A, and is assigned to B; prefers B to A, and B prefers to . In other words, and B would both be happier with each other than with their current assignment. The goal of the Resident Match is a stable matching, in which no doctor or hospital has an incentive to cheat the system. At first glance, it is not clear that a stable matching exists! In 1952, the NRMP adopted the "Boston Pool" algorithm to assign interns, so named because it had been previously used by a regional clearinghouse in the Boston area. The algorithm is often inappropriately attributed to David Gale and Lloyd Shapley, who formally analyzed the algorithm and first proved that it computes a stable matching in 1962; Gale and Shapley used the metaphor of college admissions.13 Similar algorithms have since been adopted for other matching markets, including faculty recruiting in France, university admission in Germany, public school admission in New York and Boston, and billet assignments for US Navy sailors. The stable matching problem is The Boston Pool algorithm proceeds in rounds until every position has been filled. Each round has two stages: 1. An arbitrary unassigned hospital A offers its position to the best doctor (according to the hospital's preference list) who has not already rejected it. 2. Each doctor plans to accepts the best hospital (according to her preference list) that makes her an offer. Thus, if is currently unassigned, she (tentatively) accepts the offer from A. If already has an assignment but prefers A, she rejects her existing assignment and (tentatively) accepts the new offer from A. Otherwise, rejects the new offer. For example, suppose four doctors (Dr. Quincy, Dr. Rotwang, Dr. Shephard, and Dr. Tam, represented by lower-case letters) and four hospitals (Arkham Asylum, Bethlem Royal Hospital, County General Hospital, and The Dharma Initiative, represented by upper-case letters) rank each other as follows: q A B C D r A D C B s B A C D t D B C A A B t r s t r q q s C t q r s D s r q t Given these preferences as input, the Boston Pool algorithm might proceed as follows: 12 In reality, most hospitals offer multiple internships, each doctor ranks only a subset of the hospitals and vice versa, and there are typically more internships than interested doctors. And then it starts getting complicated. 13 The "Gale-Shapley algorithm" is a prime instance of Stigler's Law of Eponymy: No scientific discovery is named after its original discoverer. In his 1980 paper that gives the law its name, the statistician Stephen Stigler claimed that this law was first proposed by sociologist Robert K. Merton. However, similar statements were previously made by Vladimir Arnol'd in the 1970's ("Discoveries are rarely attributed to the correct person."), Carl Boyer in 1968 ("Clio, the muse of history, often is fickle in attaching names to theorems!"), Alfred North Whitehead in 1917 ("Everything of importance has been said before by someone who did not discover it."), and even Stephen's father George Stigler in 1966 ("If we should ever encounter a case where a theory is named for the correct man, it will be noted."). We will see many other examples of Stigler's law in this class. 9 Algorithms 1. Arkham makes an offer to Dr. Tam. 2. Bedlam makes an offer to Dr. Rotwang. Lecture 0: Introduction [F10] 3. County makes an offer to Dr. Tam, who rejects her earlier offer from Arkham. 4. Dharma makes an offer to Dr. Shephard. (From this point on, because there is only one unmatched hospital, the algorithm has no more choices.) 5. Arkham makes an offer to Dr. Shephard, who rejects her earlier offer from Dharma. 6. Dharma makes an offer to Dr. Rotwang, who rejects her earlier offer from Bedlam. 7. Bedlam makes an offer to Dr. Tam, who rejects her earlier offer from County. 8. County makes an offer to Dr. Quincy. At this point, all pending offers are accepted, and the algorithm terminates with a matching: (A, s), (B, t), (C, q), (D, r). You can (and should) verify by brute force that this matching is stable, even though no doctor was hired by her favorite hospital, and no hospital hired its favorite doctor. In fact, this is the only stable matching for this list of preferences. Analyzing the algorithm's running time is relatively straightforward. Each hospital makes an offer to each doctor at most once, so the algorithm requires at most n2 rounds. In an actual implementation, each doctor and hospital can be identified by a unique integer between 1 and n, and the preference lists can be represented as two arrays DocPref[1 .. n][1 .. n] and HosPref[1 .. n][1 .. n], where DocPref[][r] represents the rth hospital in doctor 's preference list, and HosPref[A][r] represents the rth doctor in hospital A's preference list. With the input in this form, the Boston Pool algorithm can be implemented to run in O(n 2 ) time; we leave the details as an easy exercise. A somewhat harder exercise is to prove that there are inputs (and choices of who makes offers when) that force (n2 ) rounds before the algorithm terminates. Thus, the O(n2 ) upper bound on the worst-case running time cannot be improved; in this case, we say our analysis is tight. Correctness But why is the algorithm correct? Gale and Shapley proved that the Boston Pool algorithm always computes a stable matching as follows. The algorithm continues as long as there is at least one unfilled position; conversely, when the algorithm terminates (after at most n2 rounds), every position is filled. No doctor can accept more than one position, and no hospital can hire more than one doctor. Thus, the algorithm always computes a matching; it remains only to prove that the matching is stable. Suppose doctor is assigned to hospital A in the final matching, but prefers B. Because every doctor accepts the best offer she receives, received no offer she liked more than A. In particular, B never made an offer to . On the other hand, B made offers to every doctor they like more than . Thus, B prefers to , and so there is no instability. Surprisingly, the correctness of the algorithm does not depend on which hospital makes its offer in which round. In fact, there is a stronger sense in which the order of offers doesn't matter--no matter which unassigned hospital makes an offer in each round, the algorithm always computes the same matching! Let's say that is a feasible doctor for A if there is a stable matching that assigns doctor to hospital A. Lemma 1. During the Boston Pool algorithm, each hospital A is rejected only by doctors that are infeasible for A. Proof: We prove the lemma by induction. Consider an arbitrary round of the Boston Pool algorithm, in which doctor rejects one hospital A for another hospital B. The rejection implies that prefers B to A. 10 Algorithms Lecture 0: Introduction [F10] Every doctor that appears higher than in B's preference list has already rejected B and therefore, by the inductive hypothesis, is infeasible for B. Now consider an arbitrary matching that assigns to A. We already established that prefers B to A. If B prefers to its partner, the matching is unstable. On the other hand, if B prefers its partner to , then (by our earlier argument) its partner is infeasible, and again the matching is unstable. We conclude that there is no stable matching that assigns to A. Now let best(A) denote the highest-ranked feasible doctor on A's preference list. Lemma 1 implies that every doctor that A prefers to its final assignment is infeasible for A. On the other hand, the final matching is stable, so the doctor assigned to A is feasible for A. The following result is now immediate: Corollary 1.1. The Boston Pool algorithm assigns best(A) to A, for every hospital A. Thus, from the hospitals' point of view, the Boston Pool algorithm computes the best possible stable matching. It turns out that this is also the worst possible matching from the doctors' viewpoint! Let worst() denote the lowest-ranked feasible hospital on doctor 's preference list. Corollary 1.2. The Boston Pool algorithm assigns to worst(), for every doctor . Proof: Suppose the Boston Pool algorithm assigns doctor to hospital A; we need to show that A = worst(). Consider an arbitrary stable matching where A is not matched with but with another doctor . The previous corollary implies that A prefers = best(A) to . Because the matching is stable, must therefore prefer her assigned hopital to A. This argument works for any stable assignment, so prefers every other feasible match to A; in other words, A = worst(). A subtle consequence of these two corollaries, discovered by Dubins and Freeman in 1981, is that a doctor can potentially improve her assignment by lying about her preferences, but a hospital cannot. (However, a set of hospitals can collude so that some of their assignments improve.) Partly for this reason, the National Residency Matching Program reversed its matching algorithm in 1998, so that potential residents offer to work for hospitals in preference order, and each hospital accepts its best offer. Thus, the new algorithm computes the best possible stable matching for the doctors, and the worst possible stable matching for the hospitals. In practice, however, this modification affected less than 1% of the resident's assignments. As far as I know, the precise effect of this change on the patients is an open problem. 0.6 Why are we here, anyway? This class is ultimately about learning two skills that are crucial for all computer scientists. 1. Intuition: How to think about abstract computation. 2. Language: How to talk about abstract computation. The first goal of this course is to help you develop algorithmic intuition. How do various algorithms really work? When you see a problem for the first time, how should you attack it? How do you tell which techniques will work at all, and which ones will work best? How do you judge whether one algorithm is better than another? How do you tell whether you have the best possible solution? These are not easy questions; anyone who says differently is selling something. 11 Algorithms Lecture 0: Introduction [F10] Our second main goal is to help you develop algorithmic language. It's not enough just to understand how to solve a problem; you also have to be able to explain your solution to somebody else. I don't mean just how to turn your algorithms into working code--despite what many students (and inexperienced programmers) think, `somebody else' is not just a computer. Nobody programs alone. Code is read far more often than it is written, or even compiled. Perhaps more importantly in the short term, explaining something to somebody else is one of the best ways to clarify your own understanding. As Albert Einstein (or was it Richard Feynman?) apocryphally put it, "You do not really understand something unless you can explain it to your grandmother." Along the way, you'll pick up a bunch of algorithmic facts--mergesort runs in (n log n) time; the amortized time to search in a splay tree is O(log n); greedy algorithms usually don't produce optimal solutions; the traveling salesman problem is NP-hard--but these aren't the point of the course. You can always look up mere facts in a textbook or on the web, provided you have enough intuition and experience to know what to look for. That's why we let you bring cheat sheets to the exams; we don't want you wasting your study time trying to memorize all the facts you've seen. You'll also practice a lot of algorithm design and analysis skills--finding useful (counter)examples, developing induction proofs, solving recurrences, using big-Oh notation, using probability, giving problems crisp mathematical descriptions, and so on. These skills are incredibly useful, and it's impossible to develop good intuition and good communication skills without them, but they aren't the main point of the course either. At this point in your educational career, you should be able to pick up most of those skills on your own, once you know what you're trying to do. Unfortunately, there is no systematic procedure--no algorithm--to determine which algorithmic techniques are most effective at solving a given problem, or finding good ways to explain, analyze, optimize, or implement a given algorithm. Like many other activities (music, writing, juggling, acting, martial arts, sports, cooking, programming, teaching, etc.), the only way to master these skills is to make them your own, through practice, practice, and more practice. You can only develop good problemsolving skills by solving problems. You can only develop good communication skills by communicating. Good intuition is the product of experience, not its replacement. We can't teach you how to do well in this class. All we can do (and what we will do) is lay out some fundamental tools, show you how to use them, create opportunities for you to practice with them, and give you honest feedback, based on our own hard-won experience and intuition. The rest is up to you. Good algorithms are extremely useful, elegant, surprising, deep, even beautiful, but most importantly, algorithms are fun! I hope you will enjoy playing with them as much as I do. 12 Algorithms Lecture 0: Introduction [F10] Boethius the algorist versus Pythagoras the abacist. from Margarita Philosophica by Gregor Reisch (1503) 13 Algorithms Lecture 0: Introduction [F10] Exercises 0. Describe and analyze an algorithm that determines, given a legal arrangement of standard pieces on a standard chess board, which player will win at chess from the given starting position if both players play perfectly. [Hint: There is a one-line solution!] 1. The traditional Devonian/Cornish drinking song "The Barley Mow" has the following pseudolyrics, where container[i] is the name of a container that holds 2i ounces of beer. One version of the song uses the following containers: nipperkin, gill pot, half-pint, pint, quart, pottle, gallon, half-anker, anker, firkin, half-barrel, barrel, hogshead, pipe, well, river, and ocean. (Every container in this list is twice as big as its predecessor, except that a firkin is actually 2.25 ankers, and the last three units are just silly.) BARLEYMOW(n): "Here's a health to the barley-mow, my brave boys," "Here's a health to the barley-mow!" "We'll drink it out of the jolly brown bowl," "Here's a health to the barley-mow!" "Here's a health to the barley-mow, my brave boys," "Here's a health to the barley-mow!" for i 1 to n "We'll drink it out of the container[i], boys," "Here's a health to the barley-mow!" for j i downto 1 "The container[ j]," "And the jolly brown bowl!" "Here's a health to the barley-mow!" "Here's a health to the barley-mow, my brave boys," "Here's a health to the barley-mow!" (a) Suppose each container name container[i] is a single word, and you can sing four words a second. How long would it take you to sing BARLEYMOW(n)? (Give a tight asymptotic bound.) (b) If you want to sing this song for n > 20, you'll have to make up your own container names. To avoid repetition, these names will get progressively longer as n increases14 . Suppose container[n] has (log n) syllables, and you can sing six syllables per second. Now how long would it take you to sing BARLEYMOW(n)? (Give a tight asymptotic bound.) (c) Suppose each time you mention the name of a container, you actually drink the corresponding amount of beer: one ounce for the jolly brown bowl, and 2i ounces for each container[i]. Assuming for purposes of this problem that you are at least 21 years old, exactly how many ounces of beer would you drink if you sang BARLEYMOW(n)? (Give an exact answer, not just an asymptotic bound.) 2. Describe and analyze the Boston Pool stable matching algorithm in more detail, so that the worst-case running time is O(n2 ), as claimed earlier in the notes. 14 "We'll drink it out of the hemisemidemiyottapint, boys!" 14 Algorithms Lecture 0: Introduction [F10] 3. Prove that it is possible for the Boston Pool algorithm to execute (n2 ) rounds. (You need to describe both a suitable input and a sequence of (n2 ) valid proposals.) 4. Describe and analyze an efficient algorithm to determine whether a given set of hospital and doctor preferences has to a unique stable matching. 5. Consider a generalization of the stable matching problem, where some doctors do not rank all hospitals and some hospitals do not rank all doctors, and a doctor can be assigned to a hospital only if each appears in the other's preference list. In this case, there are three additional unstable situations: A hospital prefers an unmatched doctor to its assigned match. A doctor prefers an unmatched hospital to her assigned match. An unmatched doctor and an unmatched hospital appear in each other's preference lists. Describe and analyze an efficient algorithm that computes a stable matching in this setting. Note that a stable matching may leave some doctors and hospitals unmatched, even though their preference lists are non-empty. For example, if every doctor lists Harvard as their only acceptable hospital, and every hospital lists Dr. House as their only acceptable intern, then only House and Harvard will be matched. 6. Recall that the input to the Huntington-Hill apportionment algorithm APPORTIONCONGRESS is an array P[1 .. n], where P[i] is the population of the ith state, and an integer R, the total number of representatives to be allotted. The output is an array r[1 .. n], where r[i] is the number of representatives allotted to the ith state by the algorithm. Let P = i=1 P[i] denote the total population of the country, and let ri = R P[i]/P denote the ideal number of representatives for the ith state. (a) Prove that r[i] ri for all i. (b) Describe and analyze an algorithm that computes exactly the same congressional apportionment as APPORTIONCONGRESS in O(n log n) time. (Recall that the running time of APPORTIONCONGRESS depends on R, which could be arbitrarily larger than n.) (c) If a state's population is small relative to the other states, its ideal number ri of representatives could be close to zero; thus, tiny states are over-represented by the HuntingtonHill apportionment process. Surprisingly, this can also be true of very large states. Let = (1 + 2)/2 1.20710678119. Prove that for any > 0, there is an input to APPORTION CONGRESS with maxi P[i] = P[1], such that r[1] > ( - ) r1 . (d) Can you improve the constant in the previous question? n Copyright 2010 Jeff Erickson. Released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License (http://creativecommons.org/licenses/by-nc-sa/3.0/). Free distribution is strongly encouraged; commercial distribution is expressly forbidden. See http://www.cs.uiuc.edu/~jeffe/teaching/algorithms/ for the most recent revision. 15
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

University of Illinois, Urbana Champaign - CS - 473
AlgorithmsDepartment of Computer ScienceUniversity of Illinois at Urbana-ChampaignInstructor: Jeff EricksonTeaching Assistants: Spring 1999: Mitch Harris and Shripad Thite Summer 1999 (IMCS): Mitch Harris Summer 2000 (IMCS): Mitch Harris Fall 2000
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 1: Recursion [Fa10]Our life is frittered away by detail. Simplify, simplify. Henry David Thoreau The control of a large force is the same principle as the control of a few men: it is merely a question of dividing up their numbers. Sun
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 3: Backtracking [Fa'10]'Tis a lesson you should heed, Try, try again; If at first you don't succeed, Try, try again; Then your courage should appear, For, if you will persevere, You will conquer, never fear; Try, try again. - Thomas H.
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 6: Advanced Dynamic Programming Tricks [Fa'10]Ninety percent of science fiction is crud. But then, ninety percent of everything is crud, and it's the ten percent that isn't crud that is important. - [Theodore] Sturgeon's Law (1953)6A
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 7: Greedy Algorithms [Fa'10]The point is, ladies and gentleman, greed is good. Greed works, greed is right. Greed clarifies, cuts through, and captures the essence of the evolutionary spirit. Greed in all its forms, greed for life, mon
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 8: Matroids [Fa'10]The problem is that we attempt to solve the simplest questions cleverly, thereby rendering them unusually complex. One should seek the simple solution. - Anton Pavlovich Chekhov (c. 1890) I love deadlines. I like the
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 9: Randomized Algorithms [Fa'10]The first nuts and bolts appeared in the middle 1400's. The bolts were just screws with straight sides and a blunt end. The nuts were hand-made, and very crude. When a match was found between a nut and a
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 10: Treaps and Skip Lists [Fa'10]I thought the following four [rules] would be enough, provided that I made a firm and constant resolution not to fail even once in the observance of them. The first was never to accept anything as true
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 11: Tail Inequalities [Fa'10]If you hold a cat by the tail you learn things you cannot learn any other way. - Mark Twain11Tail InequalitiesThe simple recursive structure of skip lists made it relatively easy to derive an upper bound
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 12: Hash Tables [Fa'10]Calvin: There! I finished our secret code! Hobbes: Let's see. Calvin: I assigned each letter a totally random number, so the code will be hard to crack. For letter "A", you write 3,004,572,688. "B" is 28,731,569.
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 13: Randomized Minimum Cut [Fa'10]Jaques: But, for the seventh cause; how did you find the quarrel on the seventh cause? Touchstone: Upon a lie seven times removed:bear your body more seeming, Audrey:as thus, sir. I did dislike the cut
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 14: Amortized Analysis [Sp'10]The goode workes that men don whil they ben in good lif al amortised by synne folwyng. - Geoffrey Chaucer, "The Persones [Parson's] Tale" (c.1400) I will gladly pay you Tuesday for a hamburger today. - J.
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 15: Scapegoat and Splay Trees [Sp'10]Everything was balanced before the computers went off line. Try and adjust something, and you unbalance something else. Try and adjust that, you unbalance two more and before you know what's happene
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsE pluribus unum (Out of many, one)Lecture 16: Disjoint Sets [Sp'10]- Official motto of the United States of America John: Who's your daddy? C'mon, you know who your daddy is! Who's your daddy? D'Argo, tell him who his daddy is!" D'Argo: I'm y
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 17: Basic Graph Properties [Sp'10]Obie looked at the seein' eye dog. Then at the twenty-seven 8 by 10 color glossy pictures with the circles and arrows and a paragraph on the back of each one. . . and then he looked at the seein' eye d
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 18: Minimum Spanning Trees [Sp'10]We must all hang together, gentlemen, or else we shall most assuredly hang separately. - Benjamin Franklin, at the signing of the Declaration of Independence (July 4, 1776) It is a very sad thing that
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 19: Shortest Paths [Sp'10]Well, ya turn left by the fire station in the village and take the old post road by the reservoir and. . . no, that won't do. Best to continue straight on by the tar road until you reach the schoolhouse and th
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 20: All-Pairs Shortest PathsThe tree which fills the arms grew from the tiniest sprout; the tower of nine storeys rose from a (small) heap of earth; the journey of a thousand li commenced with a single step. - Lao-Tzu, Tao Te Ching, ch
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 21: Maximum Flows and Minimum Cuts [Fa'10]Col. Hogan: One of these wires disconnects the fuse, the other one fires the bomb. Which one would you cut, Shultz? Sgt. Schultz: Don't ask me, this is a decision for an officer. Col. Hogan: Al
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 22: Max-Flow Algorithms [Fa'10]A process cannot be understood by stopping it. Understanding must move with the flow of the process, must join it and flow with it. - The First Law of Mentat, in Frank Herbert's Dune (1965) There's a diff
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 23: Applications of Maximum Flow [Fa'10]For a long time it puzzled me how something so expensive, so leading edge, could be so useless, and then it occurred to me that a computer is a stupid machine with the ability to do incredibly sm
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 18: Extensions of Maximum Flow [Fa'10]"Who are you?" said Lunkwill, rising angrily from his seat. "What do you want?" "I am Majikthise!" announced the older one. "And I demand that I am Vroomfondel!" shouted the younger one. Majikthise
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 25: Linear Programming [Fa '10]The greatest flood has the soonest ebb; the sorest tempest the most sudden calm; the hottest love the coldest end; and from the deepest desire oftentimes ensues the deadliest hate. - Socrates Th' extremes
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 25: Linear Programming [Fa '10]The greatest flood has the soonest ebb; the sorest tempest the most sudden calm; the hottest love the coldest end; and from the deepest desire oftentimes ensues the deadliest hate. - Socrates Th' extremes
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 26: Linear Programming Algorithms [Fa'10]Simplicibus itaque verbis gaudet Mathematica Veritas, cum etiam per se simplex sit Veritatis oratio. [And thus Mathematical Truth prefers simple words, because the language of Truth is itself si
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 27: Lower Bounds [Sp'10]It was a Game called Yes and No, where Scrooge's nephew had to think of something, and the rest must find out what; he only answering to their questions yes or no, as the case was. The brisk fire of questioning
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 28: Adversary Arguments [Sp'10]An adversary means opposition and competition, but not having an adversary means grief and loneliness. - Zhuangzi (Chuang-tsu) c. 300 BC It is possible that the operator could be hit by an asteroid and yo
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 29: NP-Hard Problems [Fa'10]The wonderful thing about standards is that there are so many of them to choose from. - Real Admiral Grace Murray Hopper If a problem has no solution, it may not be a problem, but a fact - not to be solved,
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsLecture 30: Approximation Algorithms [Fa'10]Le mieux est l'ennemi du bien. [The best is the enemy of the good.] - Voltaire, La Bgueule (1772) Who shall forbid a wise skepticism, seeing that there is no practical question on which any thing mor
University of Illinois, Urbana Champaign - CS - 473
Appendix I: Proof by Induction [Fa10]AlgorithmsJeder Genieende meint, dem Baume habe es an der Frucht gelegen;aber ihm lag am Samen.[Everyone who enjoys thinks that the fundamental thing about trees is the fruit,but in fact it is the seed.] Friedric
University of Illinois, Urbana Champaign - CS - 473
Appendix II: Solving Recurrences [Fa10]AlgorithmsChange is certain. Peace is followed by disturbances; departure of evil men by theirreturn. Such recurrences should not constitute occasions for sadness but realities forawareness, so that one may be ha
University of Illinois, Urbana Champaign - CS - 473
AlgorithmsDepartment of Computer ScienceUniversity of Illinois at Urbana-ChampaignInstructor: Jeff EricksonTeaching Assistants: Spring 1999: Mitch Harris and Shripad Thite Summer 1999 (IMCS): Mitch Harris Summer 2000 (IMCS): Mitch Harris Fall 2000
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Fall 2000Homework 0, due August 31, 2000 at the beginning of className: Net ID:Alias:Neatly print your name (rst name rst, with no comma), your network ID, and a short alias into the boxes above. Do not sign your name
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Fall 2000Homework 0, due August 31, 2000 at the beginning of className: Net ID:Alias:Neatly print your name (rst name rst, with no comma), your network ID, and a short alias into the boxes above. Do not sign your name
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Fall 2002Homework 0, due September 5, 2002 at the beginning of className: Net ID:Alias:UGNeatly print your name (rst name rst, with no comma), your network ID, and an alias of your choice into the boxes above. Circle
University of Illinois, Urbana Champaign - CS - 473
CS 473G: Combinatorial Algorithms, Fall 2005Homework 0Due Thursday, September 1, 2005, at the beginning of class (12:30pm CDT)Name:Net ID:Alias:I understand the Homework Instructions and FAQ. Neatly print your full name, your NetID, and an alias of
University of Illinois, Urbana Champaign - CS - 473
CS 473U: Undergraduate Algorithms, Fall 2006Homework 0Due Friday, September 1, 2006 at noon in 3229 Siebel CenterName:Net ID:Alias:I understand the Homework Instructions and FAQ. Neatly print your full name, your NetID, and an alias of your choice
University of Illinois, Urbana Champaign - CS - 473
CS 573: Graduate Algorithms, Fall 2008Homework 0Due in class at 12:30pm, Wednesday, September 3, 2008Name:Net ID:Alias:I understand the course policies. Each student must submit their own solutions for this homework. For all future homeworks,group
University of Illinois, Urbana Champaign - CS - 473
CS 573Homework 0 (due September 1, 2010)Fall 2010CS 573: Graduate Algorithms, Fall 2010Homework 0Due Wednesday, September 1, 2010 in class This homework tests your familiarity with prerequisite material (http:/www.cs.uiuc.edu/class/fa10/cs573/stuff
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Spring 1999Final Exam (May 7, 1999)Name: Net ID:Alias:This is a closed-book, closed-notes exam!If you brought anything with you besides writing instruments and your two 8 1 11 cheat sheets, please leave it at the fro
University of Illinois, Urbana Champaign - CS - 473
CS473ugHead Banging Session #39/19/06 - 9/21/061. Championship Showdown What excitement! The Champaign Spinners and the Urbana Dreamweavers have advanced to meet each other in the World Series of Basketweaving! The World Champions will be decided by a
University of Illinois, Urbana Champaign - CS - 473
CS473ugHead Banging Session #510/03/06 - 10/05/061. Simulating Queues with Stacks A queue is a rst-in-rst-out data structure. It supports two operations push and pop. Push adds a new item to the back of the queue, while pop removes the rst item from th
University of Illinois, Urbana Champaign - CS - 473
CS473ugHead Banging Session #810/24/06 - 10/26/061. Alien Abduction Mulder and Scully have computed, for every road in the United States, the exact probability that someone driving on that road wont be abducted by aliens. Agent Mulder needs to drive fr
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Fall 2000Homework 0, due August 31, 2000 at the beginning of className: Net ID:Alias:Neatly print your name (rst name rst, with no comma), your network ID, and a short alias into the boxes above. Do not sign your name
University of Illinois, Urbana Champaign - CS - 473
CS 373Homework 0 (due 1/26/99)Spring 1999CS 373: Combinatorial Algorithms, Spring 1999http:/www-courses.cs.uiuc.edu/ cs373 Homework 0 (due January 26, 1999 by the beginning of class)Name: Net ID:Alias:Neatly print your name (rst name rst, with no c
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Fall 2000Homework 1 (due September 12, 2000 at midnight)Name: Net ID: Name: Net ID: Name: Net ID:Alias:U 3/4 1Alias:U 3/4 1Alias:U 3/4 1Starting with Homework 1, homeworks may be done in teams of up to three peop
University of Illinois, Urbana Champaign - CS - 473
CS 373Homework 1 (due 2/9/99)Spring 1999CS 373: Combinatorial Algorithms, Spring 1999http:/www-courses.cs.uiuc.edu/~cs373 Homework 1 (due February 9, 1999 by noon)Name: Net ID:Alias:Everyone must do the problems marked . Problems marked are for 1-u
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Fall 2000Homework 2 (due September 28, 2000 at midnight)Name: Net ID: Name: Net ID: Name: Net ID:Alias:U 3/4 1Alias:U 3/4 1Alias:U 3/4 1Starting with Homework 1, homeworks may be done in teams of up to three peop
University of Illinois, Urbana Champaign - CS - 473
CS 373Homework 2 (due 2/18/99)Spring 1999CS 373: Combinatorial Algorithms, Spring 1999http:/www-courses.cs.uiuc.edu/~cs373 Homework 2 (due Thu. Feb. 18, 1999 by noon)Name: Net ID:Alias:Everyone must do the problems marked . Problems marked are for
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Fall 2000Homework 3 (due October 17, 2000 at midnight)Name: Net ID: Name: Net ID: Name: Net ID:Alias:U 3/4 1Alias:U 3/4 1Alias:U 3/4 1Starting with Homework 1, homeworks may be done in teams of up to three people
University of Illinois, Urbana Champaign - CS - 473
CS 373Homework 3 (due 3/11/99)Spring 1999CS 373: Combinatorial Algorithms, Spring 1999http:/www-courses.cs.uiuc.edu/~cs373 Homework 3 (due Thu. Mar. 11, 1999 by noon)Name: Net ID:Alias:Everyone must do the problems marked . Problems marked are for
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Fall 2000Homework 4 (due October 26, 2000 at midnight)Name: Net ID: Name: Net ID: Name: Net ID:Alias:U 3/4 1Alias:U 3/4 1Alias:U 3/4 1Homeworks may be done in teams of up to three people. Each team turns in just
University of Illinois, Urbana Champaign - CS - 473
CS 373Homework 4 (due 4/1/99)Spring 1999CS 373: Combinatorial Algorithms, Spring 1999http:/www-courses.cs.uiuc.edu/~cs373 Homework 4 (due Thu. Apr. 1, 1999 by noon)Name: Net ID:Alias:Everyone must do the problems marked . Problems marked are for 1-
University of Illinois, Urbana Champaign - CS - 473
CS 373Homework 5 (due 4/22/99)Spring 1999CS 373: Combinatorial Algorithms, Spring 1999http:/www-courses.cs.uiuc.edu/~cs373 Homework 5 (due Thu. Apr. 22, 1999 by noon)Name: Net ID:Alias:Everyone must do the problems marked . Problems marked are for
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Spring 1999Midterm 1 (February 23, 1999)Name: Net ID:Alias:This is a closed-book, closed-notes exam!If you brought anything with you besides writing instruments and your 8 1 11 cheat sheet, please leave it at the fro
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Spring 1999Midterm 2 (April 6, 1999)Name: Net ID:Alias:This is a closed-book, closed-notes exam!If you brought anything with you besides writing instruments and your 8 1 11 cheat sheet, please leave it at the front o
University of Illinois, Urbana Champaign - CS - 473
CS 373: Combinatorial Algorithms, Spring 2001Homework 0, due January 23, 2001 at the beginning of className: Net ID:Alias:Neatly print your name (rst name rst, with no comma), your network ID, and a short alias into the boxes above. Do not sign your n
University of Illinois, Urbana Champaign - CS - 473
CS 373U: Combinatorial Algorithms, Spring 2004Homework 0Due January 28, 2004 at noonName:Net ID:Alias:I understand the Homework Instructions and FAQ. Neatly print your full name, your NetID, and an alias of your choice in the boxes above.Grades wi
University of Illinois, Urbana Champaign - CS - 473
CS 473G: Graduate Algorithms, Spring 2007Homework 0Due in class at 11:00am, Tuesday, January 30, 2007Name:Net ID:Alias:I understand the Course Policies. Neatly print your full name, your NetID, and an alias of your choice in the boxes above, andst
University of Illinois, Urbana Champaign - CS - 473
CS 473Homework 0 (due January 27, 2009)Spring 2009CS 473: Undergraduate Algorithms, Spring 2009Homework 0Due in class at 11:00am, Tuesday, January 27, 2009 This homework tests your familiarity with prerequisite materialbig-Oh notation, elementaryal
University of Illinois, Urbana Champaign - CS - 473
CS 473Homework 0 (due January 26, 2009)Spring 2010CS 473: Undergraduate Algorithms, Spring 2010Homework 0Due Tuesday, January 26, 2009 in class This homework tests your familiarity with prerequisite materialbig-Oh notation, elementaryalgorithms and