Given a matrix $\mathsf{a}$ of size $K\times N$, what is the best complexity of finding the minimum value?
Here is a pseudo code:
function find_min(a)
imin, jmin = 1, 1
for k = 1 to K
for n = 1 to N
if a[k, n] < a[imin, jmin]
imin = k
jmin = n
return imin, jmin
The above function needs $O(K\cdot N)$ operations. However, I think we can reduce the complexity to $O(\lg K\cdot N)$ using a heap. Am I right? Can we do better than a heap? If so, what is the best complexity of such a function?