CMU 15-110 Fall 2018: Principles of Computing
Quiz1 Practice (Due never)
- This is optional, to help you study for quiz1.
- Due the odd nature of week1, we have concluded that quiz1 should have questions that come from a fixed question bank. This is not usual. You would typically know the topics but not exact questions or question types (even when we publish practice quizzes, it's not the same as a fixed question bank!). So this makes quiz1 quite a bit easier, which is our intent! :-)
- If you want some interactive practice, try one of these:
- Try it on repl.it (press the 'Run' button!) (You might also resize the console to make it bigger.)
- Or run quiz1-practice.py on your laptop (see a TA at OH if you need help with this)
- Only these questions may appear on quiz1 (with the constants changed, but of similar size).
For example, we might change the first question below to: "Represent 5 as a 4-bit unsigned binary number". The actual quiz may contain a random subset of these questions (so perhaps not all of them)
-
Represent 21 as an 8-bit unsigned binary number
Answer:
21 = 16 + 4 + 1 = 00010101
-
Represent -9 as a 6-bit signed binary number using sign-magnitude
Answer:
+9 = 8 + 1 = 001001, so -9 = 101001 in sign-magnitude
-
Represent the string 'CbA' to decimal numbers using zero-termination. Hint: here are some ascii values: 'A' is 65, 'a' is 97, and '0' is 48
Answer:
67, 98, 65, 0
-
Represent the string 'B1' to decimal numbers using prefix-encoding Hint: here are some ascii values: 'A' is 65, 'a' is 97, and '0' is 48
Answer:
2, 66, 49
-
Represent the float 103.3001 using the mantissa,exponent representation from class
Answer:
1033001, 4
-
What is the largest unsigned int that can be represented in 4 bits? Give your answer in base 10
Answer:
1111 = 8 + 4 + 2 + 1= 15
-
Show the work to compute 213 - 104 using 10's complement:
Answer:
104 -> 895 + 1 -> 896 (so 896 equals -104 in 10's complement)
So: 213 - 104 = 213 + 896 (if we ignore the last carry) = 109.
Note: For any credit, your work would have to include both 896 and 109.
-
Show the work to compute 64 * 17 using lattice multiplication
Answer:
-
Show all 5 additions (always only adding only two numbers) used to compute 17 * 13 using egyptian multiplication:
Answer:
17 + 17 = 34 (2 17's)
34 + 34 = 68 (4 17's)
68 + 68 = 136 (8 17's)
---------
Now we note that 13 = 8 + 4 + 1, so:
----------
17 + 68 = 85 (1 17 + 4 17's -> 5 17's)
85 + 136 = 221 (5 17's + 8 17's -> 13 17's)
-
Say we started with this image from the Parity Card Trick website:
Fill in the bottom row and right column as required by the trick.
Answer:
-
Say we saw this image from the Parity Card Trick website, after we set up the board properly and after a bit was flipped:
Which bit was flipped, in (row, col) notation, where we start counting at 0 not 1 (so the top row is row 0, and the left column is col 0)?
Answer:
(1, 3)
-
Explain in 5 words or less how to always win at Nim.
Answer:
seek multiples of 4
-
Who were our guest speakers in week1, and in 10 words or less, what is one technical topic they talked about?
Answer:
Manuel and Lenore Blum, the BBS pseudo-random number generator
Note: it has to be a reasonable answer, and technical. So while
Lenore did talk about Venezuela, and it was really interesting,
that still would not get credit here.
That's it! Nothing else will appear on quiz1.