Problem 8 (+6% pts) To receive credit for this, your algorithm must run in time $\theta(n^2 \log n)$.
Write the method below which takes an n by n two dimensional array A (rows and columns indexed
from 0 to n - 1) and determines if some value appears more than once in A. If so, the method returns
any such value. If not, it returns -1. (Assume all values in A are positive).
int dupeValuesFaster(int n, int [][] A)
Problem 9 (+6% pts) To receive credit for this, your algorithm must run in time $0(n^2 \log n)$.
Write the method below which takes an n by n two dimensional array A (rows and columns indexed
from 0 to n - 1) and determines if some value appears more than once in A. If so, the method returns
an array with the coordinates of both locations. If not, the method returns null.
int [] dupeLocationsFaster(int n, int [][] A)
For example, If A is the array below, the method would return the array {1, 4, 3, 2} since
A[1][4] = A[3][2].
A
0
1
2
3
4
0
68 150 77
2
83
1
41 69
31
80 999
2
29
57 24
46 432
3
46 -32 999 112 46
4
119 100 298 34
7
However, if A[2][5] were 1000 instead of 999, then A would have no duplicate elements, and the
method would return null.