Question: 4. Let A and B be two arrays, each storing n different integer values. The goal is to design an algorithm that returns true if


4. Let A and B be two arrays, each storing n different integer values. The goal is to design an algorithm that returns true if A and B have no common values, and it returns false otherwise. For example, if the algorithm receives as input below arrays A and B the algorithm must return true as no value in A is also in B; however if the algorithm receives as input arrays A and B it must return false as the values 3 and 4 in A' also appear in B. 6 0 8 1 7 5 1 2 3 4 3 0 9 1 4 2 0 3 2 4 8 0 3 1 1 4 2 3 ' 6 4 B i. (4 marks) Write pseudocode for an algorithm as described above. You cannot use a hashmap or any other additional data structures. You cannot sort the arrays. ii. Prove that your algorithm is correct: a. (1 mark) Show that the algorithm terminates. b. (2 marks) Show that the algorithm always produces the correct answer. iii. (1 mark) Explain what the worst case for the algorithm is. iv. (3 marks) Compute the time complexity of the algorithm in the worst case. You must give the order of the time complexity using "big-Oh notation and you must explain how you computed the time complexity
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
