Hey, Iv'e got 2 questions about q2 in this exam:

קישור

1.We were asked to complete a code named has common, I completed it as follows:

go over optional strings on s1 and add all of them into the set, then go over the optional strings on s2,

and check rather they exist in the set already, if so return True value. else when the loop is done return False.

Then we were asked to tell the average time complexity regarding n1,n2,k(assuming min(n1,n2)>k).

I answered O(k*(max{n1,n2}-k)).first, considering the assumption min{n1,n2}>k can I neglect k? second, is it ok to use the maximum function when we're asked to give a supremum big O complexity?

2.We were asked to explain an efficient has_common improvement, to O(n1+n2) complexity, I suggested Karp-Rabin's fingerprint, and then recalled that it False-Positive. is it ok though? if not, can you please give a better suggestion?

Thanks.