9 Pages

14-amortize

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

Word Count: 4439

Document Preview

14: Algorithms Lecture 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. Wellington Wimpy, "Thimble Theatre" (1931) I want my two dollars! -- Johnny Gasparini [Demian Slade], "Better Off...

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.
14: Algorithms Lecture 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. Wellington Wimpy, "Thimble Theatre" (1931) I want my two dollars! -- Johnny Gasparini [Demian Slade], "Better Off Dead" (1985) 14 14.1 Amortized Analysis Incrementing a Binary Counter It is a straightforward exercise in induction, which often appears on Homework 0, to prove that any non-negative integer n can be represented as the sum of distinct powers of 2. Although some students correctly use induction on the number of bits--pulling off either the least significant bit or the most significant bit in the binary representation and letting the Recursion Fairy convert the remainder--the most commonly submitted proof uses induction on the value of the integer, as follows: Proof: The base case n = 0 is trivial. For any n > 0, the inductive hypothesis implies that there is set of distinct powers of 2 whose sum is n - 1. If we add 20 to this set, we obtain a multiset of powers of two whose sum is n, which might contain two copies of 20 . Then as long as there are two copies of any 2i in the multiset, we remove them both and insert 2i+1 in their place. The sum of the elements of the multiset is unchanged by this replacement, because 2i+1 = 2i + 2i . Each iteration decreases the size of the multiset by 1, so the replacement process must eventually terminate. When it does terminate, we have a set of distinct powers of 2 whose sum is n. This proof is describing an algorithm to increment a binary counter from n - 1 to n. Here's a more formal (and shorter!) description of the algorithm to add 1 to a binary counter. The input B is an (infinite) array of bits, where B[i] = 1 if and only if 2i appears in the sum. INCREMENT(B[0 .. ]): i0 while B[i] = 1 B[i] 0 i i+1 B[i] 1 We've already argued that INCREMENT must terminate, but how quickly? Obviously, the running time depends on the array of bits passed as input. If the first k bits are all 1s, then INCREMENT takes (k) time. The binary representation of any positive integer n is exactly lg n + 1 bits long. Thus, if B represents an integer between 0 and n, INCREMENT takes (log n) time in the worst case. 14.2 Counting from 0 to n Now suppose we want to use INCREMENT to count from 0 to n. If we only use the worst-case running time for each INCREMENT, we get an upper bound of O(n log n) on the total running time. Although this bound is correct, we can do better. There are several general methods for proving that the total running time is actually only O(n). Many of these methods are logically equivalent, but different formulations are more natural for different problems. c 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 14.2.1 The Summation (Aggregate) Method Lecture 14: Amortized Analysis [Sp'10] The easiest way to get a tighter bound is to observe that we don't need to flip (log n) bits every time INCREMENT is called. The least significant bit B[0] does flip every time, but B[1] only flips every other time, B[2] flips every 4th time, and in general, B[i] flips every 2i th time. If we start with an array full of 0's, a sequence of n INCREMENTs flips each bit B[i] exactly n/2i times. Thus, the total number of bit-flips for the entire sequence is lg n n 2i < i=0 n 2i = 2n. i=0 Thus, on average, each call to INCREMENT flips only two bits, and so runs in constant time. This `on average' is quite different from the averaging we consider with randomized algorithms. There is no probability involved; we are averaging over a sequence of operations, not the possible running times of a single operation. This averaging idea is called amortization--the amortized time for each INCREMENT is O(1). Amortization is a sleazy clever trick used by accountants to average large one-time costs over long periods of time; the most common example is calculating uniform payments for a loan, even though the borrower is paying interest on less and less capital over time. For this reason, `amortized cost' is a common synonym for amortized running time. Most textbooks call this technique for bounding amortized costs the aggregate method, or aggregate analysis, but this is just a fancy name for adding up the costs of the individual operations and dividing by the number of operations. The Summation Method. Let T (n) be the worst-case running time for a sequence of n operations. The amortized time for each operation is T (n)/n. 14.2.2 The Taxation (Accounting) Method A second method we can use to derive amortized bounds is called either the accounting method or the taxation method. Suppose it costs us a dollar to toggle a bit, so we can measure the running time of our algorithm in dollars. Time is money! Instead of paying for each bit flip when it happens, the Increment Revenue Service charges a twodollar increment tax whenever we want to set a bit from zero to one. One of those dollars is spent changing the bit from zero to one; the other is stored away as credit until we need to reset the same bit to zero. The key point here is that we always have enough credit saved up to pay for the next INCREMENT. The amortized cost of an INCREMENT is the total tax it incurs, which is exactly 2 dollars, since each INCREMENT changes just one bit from 0 to 1. It is often useful to distribute the tax income to specific pieces of the data structure. For example, for each INCREMENT, we could store one of the two dollars on the single bit that is set for 0 to 1, so that that bit can pay to reset itself back to zero later on. Taxation Method 1. Certain steps in the algorithm charge you taxes, so that the total cost incurred by the algorithm is never more than the total tax you pay. The amortized cost of an operation is the overall tax charged to you during that operation. A different way to schedule the taxes is for every bit to charge us a tax at every operation, regardless of whether the bit changes of not. Specifically, each bit B[i] charges a tax of 1/2i dollars for each INCREMENT. The total tax we are charged during each INCREMENT is i0 2-i = 2 dollars. Every time a bit B[i] actually needs to be flipped, it has collected exactly $1, which is just enough for us to pay for the flip. 2 Algorithms Lecture 14: Amortized Analysis [Sp'10] Taxation Method 2. Certain portions of the data structure charge you taxes at each operation, so that the total cost of maintaining the data structure is never more than the total taxes you pay. The amortized cost of an operation is the overall tax you pay during that operation. In both of the taxation methods, our task as algorithm analysts is to come up with an appropriate `tax schedule'. Different `schedules' can result in different amortized time bounds. The tightest bounds are obtained from tax schedules that just barely stay in the black. 14.2.3 The Charging Method Another common method of amortized analysis involves charging the cost of some steps to some other, earlier steps. The method is similar to taxation, except that we focus on where each unit of tax is (or will be) spent, rather than where is it collected. By charging the cost of some operations to earlier operations, we are overestimating the total cost of any sequence of operations, since we pay for some charges from future operations that may never actually occur. For example, in our binary counter, suppose we charge the cost of clearing a bit (changing its value from 1 to 0) to the previous operation that sets that bit (changing its value from 0 to 1). If we flip k bits during an INCREMENT, we charge k - 1 of those bit-flips to earlier bit-flips. Conversely, the single operation that sets a bit receives at most one unit of charge from the next time that bit is cleared. So instead of paying for k bit-flips, we pay for at most two: one for actually setting a bit, plus at most one charge from the future for clearing that same bit. Thus, the total amortized cost of the INCREMENT is at most two bit-flips. The Charging Method. Charge the cost of some steps of the algorithm to earlier steps, or to steps in some earlier operation. The amortized cost of the algorithm is its actual running time, minus its total charges to past operations, plus its total charge from future operations. 14.2.4 The Potential Method The most powerful method (and the hardest to use) builds on a physics metaphor of `potential energy'. Instead of associating costs or taxes with particular operations or pieces of the data structure, we represent prepaid work as potential that can be spent on later operations. The potential is a function of the entire data structure. Let Di denote our data structure after i operations, and let i denote its potential. Let ci denote the actual cost of the ith operation (which changes Di-1 into Di ). Then the amortized cost of the ith operation, denoted ai , is defined to be the actual cost plus the increase in potential: ai = ci + i - i-1 So the total amortized cost of n operations is the actual total cost plus the total increase in potential: n n n ai = i=1 i=1 ci + i - i-1 = i=1 c i + n - 0 . A potential function is valid if i - 0 0 for all i. If the potential function is valid, then the total actual cost of any sequence of operations is always less than the total amortized cost: n n n ci = i=1 i=1 ai - n i=1 ai . 3 Algorithms Lecture 14: Amortized Analysis [Sp'10] For our binary counter example, we can define the potential i after the ith INCREMENT to be the number of bits with value 1. Initially, all bits are equal to zero, so 0 = 0, and clearly i > 0 for all i > 0, so this is a valid potential function. We can describe both the actual cost of an INCREMENT and the change in potential in terms of the number of bits set to 1 and reset to 0. ci = #bits changed from 0 to 1 + #bits changed from 1 to 0 i - i-1 = #bits changed from 0 to 1 - #bits changed from 1 to 0 Thus, the amortized cost of the ith INCREMENT is ai = ci + i - i-1 = 2 #bits changed from 0 to 1 Since INCREMENT changes only one bit from 0 to 1, the amortized cost INCREMENT is 2. The Potential Method. Define a potential function for the data structure that is initially equal to zero and is always nonnegative. The amortized cost of an operation is its actual cost plus the change in potential. For this particular example, the potential is precisely the total unspent taxes paid using the taxation method, so not too surprisingly, we obtain precisely the same amortized cost. In general, however, there may be no way of interpreting the change in potential as `taxes'. Taxation and charging are useful when there is a convenient way to distribute costs to specific steps in the algorithm or components of the data structure; potential arguments allow us to argue more globally when a local distribution is difficult or impossible. Different potential functions can lead to different amortized time bounds. The trick to using the potential method is to come up with the best possible potential function. A good potential function goes up a little during any cheap/fast operation, and goes down a lot during any expensive/slow operation. Unfortunately, there is no general technique for doing this other than playing around with the data structure and trying lots of different possibilities. 14.3 Incrementing and Decrementing Now suppose we wanted a binary counter that we can both increment and decrement efficiently. A standard binary counter won't work, even in an amortized sense; if we alternate between 2k and 2k - 1, every operation costs (k) time. A nice alternative is represent a number as a pair of bit strings (P, N ), where for any bit position i, at most one of the bits P[i] and N [i] is equal to 1. The actual value of the counter is P - N . Here are algorithms to increment and decrement our double binary counter. INCREMENT(P, N ): i0 while P[i] = 1 P[i] 0 i i+1 if N [i] = 1 N [i] 0 else P[i] 1 DECREMENT(P, N ): i0 while N [i] = 1 N [i] 0 i i+1 if P[i] = 1 P[i] 0 else N [i] 1 Here's an example of these algorithms in action. Notice that any number other than zero can be represented in multiple (in fact, infinitely many) ways. 4 Algorithms Lecture 14: Amortized Analysis [Sp'10] P = 10001 P = 10000 P = 10000 P = 10000 P = 10011 P = 10010 P = 10001 ++ -- -- ++ ++ ++ N = 01100 - N = 01100 - N = 01100 - N = 01000 - N = 01001 - N = 01010 - N = 01010 P-N =7 P-N =6 P-N =7 P-N =8 P-N =7 P-N =6 P-N =5 Incrementing and decrementing a double-binary counter. Now suppose we start from (0, 0) and apply a sequence of n INCREMENTs and DECREMENTs. In the worst case, operation takes (log n) time, but what is the amortized cost? We can't use the aggregate method here, since we don't know what the sequence operations of looks like. What about the taxation method? It's not hard to prove (by induction, of course) that after either P[i] or N [i] is set to 1, there must be at least 2i operations, either INCREMENTs or DECREMENTs, before that bit is reset to 0. So if each bit P[i] and N [i] pays a tax of 2-i at each operation, we will always have enough money to pay for the next operation. Thus, the amortized cost of each operation is at most -i = 4. i0 2 2 We can get even better bounds using the potential method. Define the potential i to be the number of 1-bits in both P and N after i operations. Just as before, we have ci = #bits changed from 0 to 1 + #bits changed from 1 to 0 i - i-1 = #bits changed from 0 to 1 - #bits changed from 1 to 0 = ai = 2 #bits changed from 0 to 1 Since each operation changes at most one bit to 1, the ith operation has amortized cost ai 2. 14.4 Gray Codes An attractive alternate solution to the increment/decrement problem was independently suggested by several students. Gray codes (named after Frank Gray, who discovered them in the 1950s) are methods for representing numbers as bit strings so that successive numbers differ by only one bit. For example, here is the four-bit binary reflected Gray code for the integers 0 through 15: 0000, 0001, 0011, 0010, 0110, 0111, 0101, 0100, 1100, 1101, 1111, 1110, 1010, 1011, 1001, 1000 The general rule for incrementing a binary reflected Gray code is to invert the bit that would be set from 0 to 1 by a normal binary counter. In terms of bit-flips, this is the perfect solution; each increment of decrement by definition changes only one bit. Unfortunately, the nave algorithm to find the single bit to flip still requires (log n) time in the worst case. Thus, so the total cost of maintaining a Gray code, using the obvious algorithm, is the same as that of maintaining a normal binary counter. Fortunately, this is only true of the nave algorithm. The following algorithm, discovered by Gideon Ehrlich1 in 1973, maintains a Gray code counter in constant worst-case time per increment! The algorithm uses a separate `focus' array F [0 .. n] in addition to a Gray-code bit array G[0 .. n - 1]. EHRLICHGRAYINCREMENT(n): j F [0] F [0] 0 if j = n G[n - 1] 1 - G[n - 1] else G[ j] = 1 - G[ j] F [ j] F [ j + 1] F [ j + 1] j + 1 EHRLICHGRAYINIT(n): for i 0 to n - 1 G[i] 0 for i 0 to n F [i] i Gideon Ehrlich. Loopless algorithms for generating permutations, combinations, and other combinatorial configurations. J. Assoc. Comput. Mach. 20:500513, 1973. 1 5 Algorithms Lecture 14: Amortized Analysis [Sp'10] The EHRLICHGRAYINCREMENT algorithm obviously runs in O(1) time, even in the worst case. Here's the algorithm in action with n = 4. The first line is the Gray bit-vector G, and the second line shows the focus vector F , both in reverse order: G : 0000, 0001, 0011, 0010, 0110, 0111, 0101, 0100, 1100, 1101, 1111, 1110, 1010, 1011, 1001, 1000 F : 3210, 3211, 3220, 3212, 3310, 3311, 3230, 3213, 4210, 4211, 4220, 4212, 3410, 3411, 3240, 3214 Voodoo! I won't explain in detail how Ehrlich's algorithm works, except to point out the following invariant. Let B[i] denote the ith bit in the standard binary representation of the current number. If B[ j ] = 0 and B[ j - 1] = 1, then F [ j ] is the smallest integer k > j such that B[k] = 1; otherwise, F [ j] = j . Got that? But wait -- this algorithm only handles increments; what if we also want to decrement? Sorry, I don't have a clue. Extra credit, anyone? 14.5 Generalities and Warnings Although computer scientists usually apply amortized analysis to understand the efficiency of maintaining and querying data structures, you should remember that amortization can be applied to any sequence of numbers. Banks have been using amortization to calculate fixed payments for interest-bearing loans for centuries. The IRS allows taxpayers to amortize business expenses or gambling losses across several years for purposes of computing income taxes. Some cell phone contracts let you to apply amortization to calling time, by rolling unused minutes from one month into the next month. It's also important to remember that amortized time bounds are not unique. For a data structure that supports multiple operations, different amortization schemes can assign different costs to exactly the same algorithms. For example, consider a generic data structure that can be modified by three algorithms: FOLD, SPINDLE, and MUTILATE. One amortization scheme might imply that FOLD and SPINDLE each run in O(log n) amortized time, while MUTILATE runs in O(n) amortized time. Another scheme might imply that FOLD runs in O( n) amortized time, while SPINDLE and MUTILATE each run in O(1) amortized time. These two results are not necessarily inconsistent! Moreover, there is no general reason to prefer one of these sets of amortized time bounds over the other; our preference may depend on the context in which the data structure is used. Exercises 1. Suppose we are maintaining a data structure under a series of operations. Let f (n) denote the actual running time of the nth operation. For each of the following functions f , determine the resulting amortized cost of a single operation. (For practice, try all of the methods described in this note.) (a) f (n) is the largest integer i such that 2i divides n. (b) f (n) is the largest power of 2 that divides n. (c) f (n) = n if n is a power of 2, and f (n) = 1 otherwise. (d) f (n) = n2 if n is a power of 2, and f (n) = 1 otherwise. 2. A multistack consists of an infinite series of stacks S0 , S1 , S2 , . . . , where the ith stack Si can hold up to 3i elements. The user always pushes and pops elements from the smallest stack S0 . However, before any element can be pushed onto any full stack Si , we first pop all the elements off Si and 6 Algorithms Lecture 14: Amortized Analysis [Sp'10] push them onto stack Si+1 to make room. (Thus, if Si+1 is already full, we first recursively move all its members to Si+2 .) Similarly, before any element can be popped from any empty stack Si , we first pop 3i elements from Si+1 and push them onto Si to make room. (Thus, if Si+1 is already empty, we first recursively fill it by popping elements from Si+2 .) Moving a single element from one stack to another takes O(1) time. Here is pseudocode for the multistack operations MSPUSH and MSPOP. The internal stacks are managed with the subroutines PUSH and POP. MPUSH(x) : i0 while Si is full i i+1 while i > 0 i i-1 for j 1 to 3i PUSH(Si+1 , POP(Si )) PUSH(S0 , x) 9 MPOP(x) : i0 while Si is empty i i+1 while i > 0 i i-1 for j 1 to 3i PUSH(Si , POP(Si+1 )) return POP(S0 ) 3 Making room in a multistack, just before pushing on a new element. (a) In the worst case, how long does it take to push one more element onto a multistack containing n elements? (b) Prove that if the user never pops anything from the multistack, the amortized cost of a push operation is O(log n), where n is the maximum number of elements in the multistack during its lifetime. (c) Prove that in any intermixed sequence of pushes and pops, each push or pop operation takes O(log n) amortized time, where n is the maximum number of elements in the multistack during its lifetime. 3. Remember the difference between stacks and queues? Good. (a) Describe how to implement a queue using two stacks and O(1) additional memory, so that the amortized time for any enqueue or dequeue operation is O(1). The only access you have to the stacks is through the standard subroutines PUSH and POP. (b) A quack is a data structure combining properties of both stacks and queues. It can be viewed as a list of elements written left to right such that three operations are possible: 7 Algorithms Lecture 14: Amortized Analysis [Sp'10] Push: add a new item to the left end of the list; Pop: remove the item on the left end of the list; Pull: remove the item on the right end of the list. Implement a quack using three stacks and O(1) additional memory, so that the amortized time for any push, pop, or pull operation is O(1). In particular, each element pushed onto the quack should be stored in exactly one of the three stacks. Again, you are only allowed to access the stacks through the standard functions PUSH and POP. 4. Suppose we can insert or delete an element into a hash table in O(1) time. In order to ensure that our hash table is always big enough, without wasting a lot of memory, we will use the following global rebuilding rules: After an insertion, if the table is more than 3/4 full, we allocate a new table twice as big as our current table, insert everything into the new table, and then free the old table. After a deletion, if the table is less than 1/4 full, we allocate a new table half as big as our current table, insert everything into the new table, and then free the old table. Show that for any sequence of insertions and deletions, the amortized time per operation is still O(1). [Hint: Do not even look at the potential-function argument in CLRS; there is a much easier solution!] 5. Chicago has many tall buildings, but only some of them have a clear view of Lake Michigan. Suppose we are given an array A[1 .. n] that stores the height of n buildings on a city block, indexed from west to east. Building i has a good view of Lake Michigan if and only if every building to the east of i is shorter than i. Here is an algorithm that computes which buildings have a good view of Lake Michigan. What is the running time of this algorithm? GOODVIEW(A[1 .. n]): initialize a stack S for i 1 to n while (S not empty and A[i] > A[TOP(S)]) POP(S) PUSH(S, i) return S 6. Design and analyze a simple data structure that maintains a list of integers and supports the following operations. CREATE( ) creates and returns a new list PUSH(L, x) appends x to the end of L POP(L) deletes the last entry of L and returns it LOOKUP(L, k) returns the kth entry of L Your solution may use these primitive data structures: arrays, balanced binary search trees, heaps, queues, single or doubly linked lists, and stacks. If your algorithm uses anything fancier, you must give an explicit implementation. Your data structure must support all operations in amortized 8 Algorithms Lecture 14: Amortized Analysis [Sp'10] constant time. In addition, your data structure must support each LOOKUP in worst-case O(1) time. At all times, the size of your data structure must be linear in the number of objects it stores. 7. Suppose instead of powers of two, we represent integers as the sum of Fibonacci numbers. In other words, instead of an array of bits, we keep an array of fits, where the ith least significant fit indicates whether the sum includes the ith Fibonacci number Fi . For example, the fitstring 101110 F represents the number F6 + F4 + F3 + F2 = 8 + 3 + 2 + 1 = 14. Describe algorithms to increment and decrement a single fitstring in constant amortized time. [Hint: Most numbers can be represented by more than one fitstring!] 8. A doubly lazy binary counter represents any number as a weighted sum of powers of two, where each weight is one of four values: -1, 0, 1, or 2. (For succinctness, I'll write 1 instead of -1.) Every integer--positive, negative, or zero--has an infinite number of doubly lazy binary representations. For example, the number 13 can be represented as 1101 (the standard binary representation), or 2101 (because 2 23 - 22 + 20 = 13) or 10111 (because 24 - 22 + 21 - 20 = 13) or 11200010111 (because -210 + 29 + 2 28 + 24 - 22 + 21 - 20 = 13). To increment a doubly lazy binary counter, we add 1 to the least significant bit, then carry the rightmost 2 (if any). To decrement, we subtract 1 from the lest significant bit, and then borrow the rightmost 1 (if any). LAZYINCREMENT(B[0 .. n]): B[0] B[0] + 1 for i 1 to n - 1 if B[i] = 2 B[i] 0 B[i + 1] B[i + 1] + 1 return LAZYDECREMENT(B[0 .. n]): B[0] B[0] - 1 for i 1 to n - 1 if B[i] = -1 B[i] 1 B[i + 1] B[i + 1] - 1 return For example, here is a doubly lazy binary count from zero up to twenty and then back down to zero. The bits are written with the least significant bit B[0] on the right, omitting all leading 0's 0 - 1 - 10 - 11 - 20 - 101 - 110 - 111 - 120 - 201 - 210 - 1011 - 1020 - 1101 - 1110 - 1111 - 1120 - 1201 - 1210 - 2011 - 2020 - 2011 - 2010 - 2001 - 2000 - 2011 - 2110 - 2101 - 1100 - 1111 - 1010 - 1001 - 1000 - 1011 - 1110 - 1101 - 100 - 111 - 10 - 1 - 0 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Prove that for any intermixed sequence of increments and decrements of a doubly lazy binary number, starting with 0, the amortized time for each operation is O(1). Do not assume, as in the example above, that all the increments come before all the decrements. c 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. 9
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
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!&quot; 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]&quot;Who are you?&quot; said Lunkwill, rising angrily from his seat. &quot;What do you want?&quot; &quot;I am Majikthise!&quot; announced the older one. &quot;And I demand that I am Vroomfondel!&quot; 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
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
Tulane - GEOL - 212
2 Component Phase DiagramsEENS 2110MineralogyTulane UniversityProf. Stephen A. NelsonTWO COMPONENT (BINARY) PHASE DIAGRAMSThis document last updated on 07-Feb-2011Experimental Determination of 2-Component Phase DiagramsAs an example, we're going t
Tulane - GEOL - 212
Contact MetamorphismEENS 2120Prof. Stephen A. NelsonPetrologyTulane UniversityContact MetamorphismThis document last updated on 30-Mar-2011As discussed previously, contact metamorphism occurs as a result of a high geothermalgradient produced local
Tulane - GEOL - 212
General Classification of Igneous RocksEENS 2120Prof. Stephen A. NelsonPetrologyTulane UniversityGeneral Classification of Igneous RocksThis document last updated on 11-Jan-2011Classification of igneous rocks is one of the most confusing aspects of
Tulane - GEOL - 212
Magmatic DifferentiationEENS 2120Prof. Stephen A. NelsonPetrologyTulane UniversityMagmatic DifferentiationThis document last updated on 23-Jan-2011Chemical Variation in Rock SuitesSoon after geologists began doing chemical analyses of igneous rock
Tulane - GEOL - 212
Metamorphic Mineral AssemblagesEENS 2120Prof. Stephen A. NelsonPetrologyTulane UniversityMetamorphic Mineral AssemblagesThis document last updated on 21-Mar-2011The mineral assemblages that occur in metamorphic rocks depend on four factors:The bul
Tulane - GEOL - 212
Metamorphic ReactionsEENS 212PetrologyProf. Stephen A. NelsonTulane UniversityMetamorphic Reactions, Isograds, and Reaction MechanismsThis document last updated on 22-Mar-2011Types of Metamorphic ReactionsChemical reactions that take place during
Tulane - GEOL - 212
Metamorphic TexturesEENS 2120Prof. Stephen A. NelsonPetrologyTulane UniversityMetamorphic Rock TexturesThis document last updated on 10-Mar-2011Metamorphic rocks exhibit a variety of textures. These can range from textures similar to theoriginal p
Tulane - GEOL - 212
Regional MetamorphismEENS 2120Prof. Stephen A. NelsonPetrologyTulane UniversityRegional MetamorphismThis document last updated on 31-Mar-2011Regional metamorphism is metamorphism that occurs over broad areas of the crust. Mostregionally metamorpho
Tulane - GEOL - 212
Textures of Igneous RocksEENS 212 Prof. Stephen A. NelsonPetrology Tulane UniversityTextures of Igneous RocksThis document last updated on 12-Feb-2004Introduction to Igneous Rocks An igneous rock is any crystalline or glassy rock that forms from cool
Tulane - GEOL - 212
Thermodynamics and MetamorphismEENS 212Prof. Stephen A. NelsonThermodynamics and MetamorphismPetrologyTulane UniversityThis document last updated on 18-Mar-2010Equilibrium and ThermodynamicsAlthough the stability relationships between various phas
Tulane - GEOL - 212
Triangular Plots in Metamorphic PetrologyEENS 212Prof. Stephen A. NelsonTriangular Plots in Metamorphic PetrologyPetrologyTulane UniversityThis document last updated on 15-Mar-2010Like igneous rocks, most metamorphic rocks are composed of 9 or more