SAMPLE WRITTEN EXAM #3 - ANSWERS - SPRING 2018 1. (a) C - transmission between hosts is done by wire or wireless B - packets are transmitted at the IP level (IP doesn't make packets) D - between applications, logical connection consists of packets A - applications communicating is the highest layer/abstraction (b) link (c) B (d) packet number, destination address (f) TCP (g) 2**16 (h) 2**24 2. (a) 24t (b) 3t (c) 3t for first set + t for each of additional 9 sets = 12t (d) ------------- -----------[ ]--| |-- \ / | | -----------[ ]--| 4-input |-- \ \ / / | Butterfly | -----------[ ]--| Network |-- \ \/\/ / | | -----------[ ]--| |-- \/\/\/\/ ------------- /\/\/\/\ ------------- -----------[ ]--| |-- / /\/\ \ | | -----------[ ]--| 4-input |-- / / \ \ | Butterfly | -----------[ ]--| Network |-- / \ | | -----------[ ]--| |-- ------------- (e) A connects to Y while B connect to X. A tries to connect to X to complete a circuit but gets blocked forever, and B tries to connect to Y to complete a circuit and gets blocked forever. 3. (a) randint(0,7) randint(7,11) randint(0,7) * 2 - 2 3**randint(0,5) primes[randint(0,10)] (b) randrange(1,11) 1 number != 10 number > maximum spin() 4. (a) ELECTIVE (b) RUBY (c) (Note: o is a one-way function that is commutative and associative) B o a = A o b (g o b) o a = (g o a) o b g o (b o a) = g o (a o b) (associative property) g o (a o b) = g o (a o b) (commutative property) Since o is a one-way function, it is very hard to compute a from K = a o B, or to compute b from K = b o A. (d) C = (M**e ) % n A A M = (C**d ) % n A A 5. (a) A (b) no (if the person is healthy, the contagious function must return false) (c) def healthy(matrix, i, j): if matrix[i][j] == 4: return true else: return false (d) def contagious(matrix, i, j): if matrix[i][j] == 1 or matrix[i][j] == 2: return true else: return false (e) randint(0,99), 35 (f) i = 24, j = 19 (when i = 0 or j = 0, subtracting one gives -1 which is actually a valid subscript in Python!)