In class test held on 3.11.15 - Department of Computer Science and

advertisement
Birkbeck College
Department of Computer Science and Information Systems
Introduction to Computer Systems
In-Class Test (Open Book)
S.J. Maybank
3 November 2015
rd
Write your name (family name included) below this line:
This question sheet includes space for the answers and for the calculations which lead
to the answers. Ask for more paper if you require it. Be sure to write your name on any
paper which you hand in to be marked.
Calculators, laptops, mobile telephones and other electronic devices are not permitted.
There are 10 questions. Each question has 5 marks. Answer all questions.
Question 1 (5 marks)
a) Write out the truth table for the Boolean expression NOT(A) OR B.
Answer:
b) Let x be a variable that takes integer values. Write down a Boolean expression
that has the value True if the value of x is in the range 0 to 5 inclusive, and that
has the value False otherwise.
Answer:
1
Question 2 (5 marks)
Let A, B, C be Boolean variables.
a) Find a Boolean expression that has the value True if A, B, C all have the value
True and that has the value False otherwise.
Answer:
b) Find a Boolean expression that has the value True if at least one of A, B, C has
the value True and that has the value False otherwise.
Answer:
Question 3 (5 marks)
Carry out the following calculations. In all cases show your working.
a) Convert the decimal number 23 to binary.
Answer:
b) Convert the decimal fraction 9/8 to a binary fraction. Give your answer in the form
of a string of bits with a radix point.
Answer:
Question 3 is continued on the next page
2
c) Add the binary numbers 10111 and 10101.
Answer:
Question 4 (5 marks)
Carry out the following calculations. In all cases show your working.
(a) Find the four bit excess notation for the decimal integer 3.
Answer:
(b) Subtract the binary number 1011 from the binary number 11101.
Answer:
(c) Consider the binary fractions 0.00, 0.01, 0.10, 0.11, 1.00. Which of these five binary
fractions are less than the decimal fraction 1/3? Justify your answer.
Answer:
3
Question 5 (5 marks)
a) Obtain the four bit two’s complement representation of the decimal integer 6.
Answer:
b) Describe the rule for obtaining the two’s complement representation of a number
from the two’s complement representation of the negative of the number. Apply the
rule to the 8 bit two’s complement representation of the decimal integer 44, namely
00101100.
Question 6 (5 marks)
A floating point notation contains eight bits, namely s, e1, e2, e3, m1, m2, m3, m4 in
order from left to right. The sign bit s is 1 if the number is strictly less than 0 and 0
otherwise. The bits e1, e2, e3 represent the exponent in 3 bit excess notation. The bits
m1, m2, m3, m4 are the leftmost (most significant) four bits of the mantissa.
Find the floating point representation of the number -2+(1/4). Show your working.
Answer:
4
Question 7 (5 marks)
The floating point representation described in Q. 6 is used in this question. Find the
decimal fraction with the floating point representation 01011101. Show your working.
Answer:
Question 8 (5 marks)
Consider the following pseudo code, in which the initial value of the variable x is 1.
x=1
count = 0
While count <= 1
x = (x/2)+(1/x)
count = count+1
EndWhile
Print(x)
The / represents exact division with no truncation.
a) What value of x is printed? Justify your answer.
Answer:
Question 8 is continued on the next page
5
b) Describe the action of the code when the initial value of x is an exact solution to the
mathematical equation x = (x/2)+(1/x). It is not necessary to find the solutions of the
equation.
Answer:
Question 9 (5 marks)
Consider the following pseudo code, in which the value of the variable n is a strictly
positive integer.
k=1
While 2𝑘+1 ≤ 𝑛
k = k+1
EndWhile
Print(k)
Edit the pseudo code to produce new pseudo code that prints out an integer k such that
𝑘 2 ≤ 𝑛 < (𝑘 + 1)2
Write out the new pseudo code in full.
Answer:
6
Question 10 (5 marks)
Data is read from a hard drive at 125 MB/s (Megabytes per second). The disk rotates at
10,000 revolutions per minute. How many revolutions are necessary in order to read 1
MB? In your answer take into account a seek time of 9 ms (milliseconds) and a latency
of 3 ms. Justify your answer.
Answer:
End of the Test
7
Download