MIT6_042JS10_lec18_sol

MIT6_042JS10_lec18_sol - Massachusetts Institute of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Massachusetts Institute of Technology 6.042J/18.062J, Spring ’10 : Mathematics for Computer Science March 15 Prof. Albert R. Meyer revised March 15, 2010, 675 minutes Solutions to In-Class Problems Week 7, Mon. Problem 1. Let G be the graph below 1 . Carefully explain why χ ( G ) = 4 . Solution. Four colors are sufficient, so χ ( G ) 4 . red white white blue blue red green Figure 1: A 4-coloring of the Graph Now assume χ ( G ) = 3 . We may assume the top vertex is colored red. The top two triangles require 3 colors each, and since they share the top red vertex, they must have the other two colors, white and blue, at their bases, as in Figure 1 . Now the bottom two vertices are both adjacent to vertices colored white and blue, and cannot have the same color since they are adjacent, so there is no alternative but to color one with a third color and the other with a fourth color, contradicting the assumption that 3 colors are enough. Hence, χ ( G ) > 3 . This together with the coloring of Figure 1 implies that χ ( G ) = 4 . Creative Commons 2010, Prof. Albert R. Meyer . 1 From Discrete Mathematics , Lov´asz, Pelikan, and Vesztergombi. Springer, 2003. Exercise 13.3.1
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Solutions to In-Class Problems Week 7, Mon. 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. Programming language compilers face the problem of assigning each variable in a program to a register. Computers usually have few registers, however, so they must be used wisely and reused often. This is called the register allocation problem. 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 first step, we no longer need b and can overwrite the register that holds its value. Also, f and h may use the same register; once f + 1 is evaluated in the last step, the register holding the value of f can be overwritten.(Assume that the computer carries out each step in the order listed and that
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the 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.

Page1 / 7

MIT6_042JS10_lec18_sol - Massachusetts Institute of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online