CS442, Spring 2006, HW #1 Answers 1. (a) 191, 168, 137, 104, 75, ... (b) 1, 1, 1, 1, 1 2. (a) 1 image is 2856 x 2142 = 6,177,552 pixels = 6 Mpixels (b) each pixel is 3 bytes, so 1 image is 6,177,552 x 3 = 18,352,656 bytes Our storage is 128 Mbytes = 128 x 1024 x 1024 = 134,217,728 bytes. So, we will be able to store 134,217,728 / 18,353,656 = 7 images (pics). 3.(a) MichaelEatsMammals = F chickensAreMammals = F MichaelEatsChicken = T so chickensAreMammals and MichaelEatsChicken = F and T = F not (chickensAreMammals and MichaelEatsChicken) = T MichaelEatsMammals or not(chickensAreMammals and MichaelEatsChicken) = F or T = T (b) MichaelEatsMammals = F batsAreMammals = F MichaelEatsBats = T so batsAreMammals and MichaelEatsBats = F and T = F not(batsAreMammals and MichaelEatsBats) = T MichaelEatsMammals or not(batsAreMammals and MichaelEatsBats) = T 4. [ML: There was some confusion about how the relays work. If there is power to the magnet, the switch is OFF. If there is no power to the magnet, the switch is ON.] Each time either A or B is OFF (false), we can see that the power source is connected directly to the output, so it is ON. When both A and B are ON (true), both switches that connect the power source to the output are "closed" (electricity doesn't flow through them), so the output will be OFF. The relationship between A, B, and output C looks like not(A and B) or (not A) or (not B) or neither-nor, etc. A B C ----------- F F T F F T T F T T T F 5. There are a lot of possibilities here, a lot of other fields of study can have their own way of implementing bits. Anyway, here are some things to keep in mind when thinking about this problem: - 0s and 1s have to be implemented by 2 different objects (when you see something, you have to know right away if it is a 1 or a 0). Example: you have 2 tubes, one is red, the other one is blue; if you have a ball rolling down in the red tube, that's a 1, of you have a ball rolling down the blue tube, it's a 0 . - The "NOT" gate has to reverse a bit, so if it gets a 1, it has to make that into a 0, and same with 0. In "computer science language" that would be: if a NOT gate gets 0 as an input, it outputs a 1. If it gets a 1 as an input it outputs a 0. For the tube example, we'd need the tubes to cross over so that a ball in the red tube results in a ball in the blue tube and vice versa). - The "OR" gate has to function in a way that would be consistent with the truth table the "OR" operation, so it has 2 bits as an input and it outputs the result of the OR operation between the 2 bits. For the tube example, some sort of mechanism like the one shown in class is needed to ensure that we get a ball in the output red tube if and only if there was a ball in one of the input red tubes. 6. Take 2, take 2, take 2, take 2. 7. In order to have all the powers of 2, we would have to have an infinite sequence of 1-s as an input. That's because the differences are the same as the sequence itself---it will never converge on differences of all zeroes.