I assume that this code ideally representation of O(n^2) complexity. The reason is for function in another for function
for (int i = 0; i < array. length; i++)
for (int j = 0; j < array.length; j++)
System.out.println(array[i] + "," + arrayfj]);
Also, I read that code below is represent O(ab) time complexity. But why is that way? I don’t undersant, because if (arrayA[i] < arrayS[j]) , this is constant and we can ignore that.
for (int i = 0; i < arrayA.length; i++)
for (int j = 0; j < arrayB.length; j++)
if (arrayA[i] < arrayS[j])
System.out.println(arrayA[i] + + arrayBfj]);
This also mentioned as O(ab), although for (int k = 0; k < 160800; k++) is also as constant
for (int i = 0j i < arrayA.length; i++)
for (int j = 0; j < arrayB.length; j++)
for (int k = 0; k < 160800; k++)
System.out.println(arrayA[i] + "," + arrayB[j]);
Different sites write different information about it.
>Solution :
If the first case, each array is the same length (n), and n*n prints are done.
In the second, the sizes of the arrays are a & b, and a*b ifs are done, and (potentially) that many prints are done (maybe everything in A is less than everything in B).
In the thirs, the sizes of the arrays are a & b, and (a*b)*160800 prints are done, but the constant can be ignored.