Question IV (20 points): Consider the following algorithm, where the input is two arrays of sizes n and m, respectively.
boolean arraysEqual(int[] array1, int[] array2){
int n = array1.length;
int m = array2.length;
if (n == m)
return false;
for(int j = 0; j < n; j++){
for(int k = 0; k < m; k++){
if((array1[j] < j) && (array2[k] < k))
return false;
}
}
return true;
}
1. (7 points) What is the best-case time complexity of this algorithm? Justify your answer, indicating which statement did you use to find the complexity.
2. (8 points) What is the worst-case time complexity of this algorithm? Justify your answer, indicating which statement did you use to find the complexity.
3. (5 points) What is the space complexity of this algorithm? Justify your answer.