So I've been stuck on this problem for quite a while now and I figured, I can get some support from this community as its my last resort
Algorithm gibby(A, B, n)
Input: arrays of integers, A and B, both of length n
Output: integer value
lal := 0
for i := 0 to n-1
for j := 0 to n-1
lal := lal + (A[i] * B[j])
endfor
endfor
return lal
I'm I right thinking that this has a time complexity of 0(N^2), if I'm mistaken please elaborate as this would be greatly appreciated.
Also how can I create another algorithm that computes exactly the same thing as the algorithm above but has a time complexity of 0(N)?
Thank you in advance.