This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Massachusetts Institute of Technology 6.042J/18.062J, Spring ’10 : Mathematics for Computer Science March 15 Prof. Albert R. Meyer revised March 2, 2010, 734 minutes In-Class Problems Week 7, Mon. Problem 1. Let G be the graph below 1 . Carefully explain why χ ( G ) = 4 . Problem 2. A portion of a computer program consists of a sequence of calculations where the results are stored in variables, like this: Inputs: a,b Step 1 . c = a + b 2 . d = a ∗ c 3 . e = c + 3 4 . f = c − e 5 . g = a + f 6 . h = f + 1 Outputs: d,g,h A computer can perform such calculations most quickly if the value of each variable is stored in a register , a chunk of very fast memory inside the microprocessor. Computers usually have few registers, however, so they must be used wisely and reused often. The problem of assigning each variable in a program to a register is called register allocation . In the example above, variables a and b must be assigned different registers, because they hold distinct input values. Furthermore, c and d must be assigned different registers; if they used the same one, then the value of c would be overwritten in the second step and we’d get the wrong answer in the third step. On the other hand, variables b and d may use the same register; after the Creative Commons 2010, Prof. Albert R. Meyer . 1 From Discrete Mathematics , Lov´asz, Pelikan, and Vesztergombi. Springer, 2003. Exercise 13.3.1 2 In-Class Problems Week 7, Mon....
View Full Document
This note was uploaded on 05/27/2011 for the course CS 6.042J taught by Professor Prof.albertr.meyer during the Spring '11 term at MIT.
- Spring '11
- Computer Science