What would you say is the time complexity on Landau Symbols for the following:
for(int i = 0; i < n; i++) {
for(int j = 1; j < n; j = j * 2) {
if (j-i > n) {
for (int k = 1; k < n; k++) {
System.out.println("Hello");
}
} else {
System.out.println("Hi");
}
}
}
I would guess 0(n)0(log2n)(O n*n) ∈ O(n3 log n), do you have better suggestions?
Aucun commentaire:
Enregistrer un commentaire