Hey I am studying for my intro algorithms class final and I'm not sure if I'm understanding this question correctly (its from a sample final exam). If someone could explain this to me that would be awesome.
The following code processes A which is an n-by-n matrix of ints. The method nextInt() is O(1), and the method findMax() is O(n). What is the complexity of the given code as a function of the problem size n? Show the details of your analysis.
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++)
A[i][j] = random.nextInt();
System.out.println(findMax(A[i]));
}
Without the methods the for loop complexity is O(n^2). Now the random.nextInt() complexity is O(1) but it is run n^n time does this effect the complexity of this. Sorry I'm a little sleep deprive. If someone can help me answer this question that would be awesome