Q)Two arrays A and B each have n elements. The elements arenot necessarily sorte
ID: 3612794 • Letter: Q
Question
Q)Two arrays A and B each have n elements. The elements arenot necessarily sorted. Each array can contain repeatedelements. We say they are disjoint if they contain no elementsin common. We wish to determine whether arrays A and B aredisjoint. If they are disjoint we return null and if not wewish to know the indices where a common element exists.
a. The following is a proposed solution
for i = 0 to n-1 {
for j = 0 to n-1 {
if(A[i] == B[j] return (i,j)
}}
returnnull