MIT6_042JS10_lec18_prob

MIT6_042JS10_lec18_prob - Massachusetts Institute of...

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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

{[ snackBarMessage ]}

Page1 / 4

MIT6_042JS10_lec18_prob - 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