Docsity

Algorithmic Problem Solving Exam: University of Nottingham, School of Computer Science, Exams of Mathematics

Toggle sidebar
bg1
G51APS
The University of Nottingham
SCHOOL OF COMPUTER SCIENCE
A LEVEL A MODULE, AUTUMN 2007–2008
ALGORITHMIC PROBLEM SOLVING
Time allowed 1 hour 30 minutes
Candidates must NOT start writing their answers until told to do so.
Answer TWO questions.
Marks available for sections of questions are
shown in brackets in the right-hand margin.
Dictionaries are not allowed with one exception. Those whose first language is not English may use a
standard translation dictionary to translate between that language and English provided that neither
language is the subject of this examination. Subject specification translation dictionaries are not permitted.
No electronic devices capable of storing and retrieving text, including electronic dictionaries, may be used.
DO NOT turn examination paper over until instructed to do so
G51APS Turn over
pf3
pf4
pf5

Partial preview of the text

Download Algorithmic Problem Solving Exam: University of Nottingham, School of Computer Science and more Exams Mathematics in PDF only on Docsity!

G51APS

The University of Nottingham

SCHOOL OF COMPUTER SCIENCE

A LEVEL A MODULE, AUTUMN 2007–

ALGORITHMIC PROBLEM SOLVING

Time allowed 1 hour 30 minutes

Candidates must NOT start writing their answers until told to do so.

Answer TWO questions. Marks available for sections of questions are shown in brackets in the right-hand margin.

Dictionaries are not allowed with one exception. Those whose first language is not English may use a standard translation dictionary to translate between that language and English provided that neither language is the subject of this examination. Subject specification translation dictionaries are not permitted.

No electronic devices capable of storing and retrieving text, including electronic dictionaries, may be used.

DO NOT turn examination paper over until instructed to do so

G51APS Turn over

1 a) Table 1.1 shows a list of expressions and assignments to the variables in the expressions. State for each, whether or not the expression is an invariant of the assignment. (5)

Assignment Expression Invariant? n := n+7 n mod 14? n := n+14 n mod 7? m , n := m+3 , n+7 3 ×m − 7 ×n? m , n := m+7 , n+3 3 ×m − 7 ×n? m , n := m+1 , n+3 even.m = even.n?

Table 1.1 Fill in entries marked “?”

b) A fuse, when lit at one end, burns for a specified period of time. For example, a 1 -minute fuse will burn for exactly one minute. The rate at which a fuse burns is irregular. If an m -minute fuse is cut into two pieces, one of the pieces will burn for n minutes and the other for m−n minutes, but there is no way of determining n. For example, suppose you have two 60 -minute fuses. Then it is possible to clock 45 minutes as follows. Light the first fuse at one end and the second fuse at both ends. When the second fuse has burnt out, light the other end of the first fuse. When this has burnt out, 45 minutes have elapsed. Suppose you are given two fuses. One burns for 24 minutes and the other for 28 minutes. Show how to clock the following times. State clearly how and when the ends of the fuses are lit and from which point the timing starts. (i) 20 minutes (ii) 19 minutes (iii) 14 minutes (iv) 10 minutes (v) 5 minutes (10) c) Suppose you have a balance and “widgets” of weights 30 , 31 , 32 ,... , 3 n^ ,... , one of each weight. Suppose you are given a “fudget”, which is claimed to have weight w , where w is a strictly positive natural number. By placing the fudget on one side of the balance together with a number (possibly zero) of widgets, and placing a number of widgets on the other side of the balance, it is possible to check the claimed weight. For example, to check whether or not w is 34 , the fudget and the widget of weight 3 should be placed on one side of the balance, and the widgets of weights 1 , 9 and 27 should be placed on the other side of the balance. If the balance does not tip to either side, w+3 = 1+9+27 , i.e. w = 34. Complete the following table showing how to use the widgets to weigh various weights. Two rows have been completed as illustration. (10)

G51APS

3 a) Figure 3.1 (at the end of this examination paper) depicts the move relation in a two-person game. The nodes represent positions in the game, and the edges represent moves. Players take it in turns to make a move; a player who is unable to move loses. Annotate each node of fig. 3.1 with the mex number of the position. Hand in the annotated copy of the figure securely fastened to your examination book. (10) b) Consider a game which is the sum of two games. The left game is the one shown in fig. 3.1. In the right game, 1 or 2 matches may be removed from a pile of matches. In the sum game, a move is made by choosing to play in the left game, or choosing to play in the right game. The game ends when it is not possible to move in either game; the player whose turn it is to play loses. The table below shows a number of different positions in this game. A position is given by a pair: the label of a node in the left game, and the number of matches in the right game. Complete the table by filling in, for each position, “losing” if the position is a losing position, or the label of one of the nodes in fig. 3.1, or the number 1 or the number 2. If a label is entered, it means move to the node with that label in the left game, and if a number is entered it means remove that number of matches in the right game. (For example, “N” means move from the current position in the left game to the position labelled “N”; “ 1 ” means remove 1 match from the pile of matches. (5)

Left Game Right Game “losing” or winning move Q 7? H 22? N 9? J 9? E 8?

Table 3.1 Fill in entries marked “?”

c) A game is played with a single pile of matches. An allowed move is to reduce the number of matches to at least one half. Formally, if there are m matches a move is to assign to m a number n such that m÷ 2 ≤ n < m. (The integer division m÷ 2 is evaluated by rounding down to the nearest integer.) For example, if there is one match the number can be reduced to zero, if there are 4 matches the number can be reduced to 2 or 3 , and if there are 7 matches the number can be reduced to 3 , 4 , 5 or 6. The game ends when there are 0 matches; the player whose turn it is to play then loses. (i) Construct a table that shows, for each number m from 0 thru 14 , whether m matches is a winning or losing position. (2) (ii) From which positions is it possible to move to a position with m matches? (Take care in the case that m is 0 .) Suppose m is greater than 0 and m matches is a losing position. What is the smallest number n that is greater than m and is such that n is also a losing position? (Check your formula against the table you have just constructed.) (3) (iii) Using your formula, give a general boolean expression that determines whether m matches is a losing position. Verify your formula by induction. (5)

G51APS

Figure 3.1 This sheet should be handed in with your examination book

G51APS End