itc revision
i fucking hate this mod

question 1
consider the UML diagram below. which of the following statements is true? (DEVICE points to SIMULATE, AGENT points to LOGIN and SIMULATE).

explanation: for include / extends relations, the arrow is always pointing towards the base case. in the case of SYNTHESISE DATA, its base is LOG IN, so you need to LOG IN before you can SYNTHESISE DATA, but to LOG IN you must FILE RECORD.
question 2
two algorithms are implemented. one of them is constant time, and the other is linear time. both are executed on the same input, on the same computer. which of the following is true, assuming both will eventually terminate?
explanation there are indeed algorithms which are “theoretically” constant time but the constant term is so large that other non-constant time algorithms will outperform it, but in the majority of cases constant time will outperform linear time. you can’t say for sure, though. more info
question 3
what time complexity is the following algorithm?
def func(n):
for i in range(4):
for j in range(n):
for k in range(n):
print([i*j*k*l for l in range(n)])
explanation: it’s three nested loops reliant on n, the constant scaling factor of 4 doesn’t matter.
question 4
consider the following query. assuming the query executes successfully, which of these statements can be assumed to be true with 100% certainty?
SELECT student_id FROM students WHERE module_id in
(SELECT module_id FROM modules WHERE professor_id =
(SELECT professor_id FROM professors WHERE years_experience > 10);
explanation: very tricky question. in SQL the syntax of ‘=’ indicates that the subquery only returns one row, and if it did, it would error out, but the question states that it executes successfully.
question 5
a music fan wants to create an entity-relationship diagram of their favorite bands. assume a band can create many albums, an album can contain many songs, and a song can ‘feature’ exactly one other band. which of the following is an incorrect assumption, based off of the information provided?
explanation: note that we say a song can feature another Band, not that it must. therefore, our Feature column can be NULL.
question 6
which of the following algorithms would have exponential time complexity?
explanation: remember your comarch! an N-bit processor will have 2^N memory addresses.
question 7
alice wants to send bob a message, and both alice and bob have valid RSA keypairs. alice and bob also share a secret K which no other people know. eve is a malicious eavesdropper who can read their transmissions. which of the following is true?
explanation: option 1 is wrong because eve can decrypt with alice’s public key. option 2 is wrong because the message could be from bob too (both share the secret K). option 3 is wrong because nobody except alice would be able to decrypt it. option 4 is correct because if bob can decrypt the message with alice’s public key, that means the message was encrypted with alice’s private key.
question 8
program A takes 10 seconds to compute 100 inputs, 50 seconds to compute 500 inputs, and 200 seconds to compute 2000 inputs. program B takes 1 second to compute 100 inputs, 4 seconds to compute 200 inputs. and 16 seconds to compute 400 inputs. for what number of inputs will their running times coincide? (ignore the trivial solution of 0 inputs)
explanation: program A is linear while program B is quadratic. running time of each program can be expressed as some f_i(n) where n is the number of inputs. f_a(n) = n/10, f_b(n) = n^2/10000. you can solve this as a quadratic or whatever but option 2 is correct here
question 9
which of these is true (assume that we want our resulting scheme to be secure and functional)?
explanation: option 1 is wrong - the key must be an invertible matrix. option 3 is wrong - N must consist of two large primes, (consider the case where N is 2x3x5x7… very trivially factorable). option 4 is wrong - it has to be 64 bit. option 2 is correct, because if the plaintext is larger than the modulus, you lose data.
question 10
what is the time complexity of the following program? take m as the length of the string, and n as the length of the substring.
def find_substr(substring, string, index):
if len(substring) + index > len(string): return False
else:
for i in range(len(substring)):
if substring[i] != string[index+i]:
return find_substr(substring, string, index+1)
return True
explanation: it will iterate through the inner loop of length m at worst n times, so the answer is O(n*m).