Home > Net > Consult a great god! Big O order of magnitude of this method is how much???
Consult a great god! Big O order of magnitude of this method is how much???
Time:10-03
The static void Print_Triangle (int n) { For (int I=1, j=1; I & lt;=2 * n - 1; I++) { If (n - j & lt; I & amp; & I & lt;=n - 1 + j) The Console. Write (" * "); The else The Console. Write (" ");
If (I==2 * n - 1 & amp; & (I + 1)/2 & gt; J) { i=0; j++; Console. WriteLine (); } } }
I used up all my possessions points ~
CodePudding user response:
Do you want to ask this time complexity of the program?
CodePudding user response:
O (N)
CodePudding user response:
Yes, feeling is n but also think is n2
CodePudding user response:
I do think, though only a layer of loop, but this cycle is repeated with the ~
CodePudding user response:
Apparently is O (n * n)
CodePudding user response:
Print_Triangle Print the triangle Triangle is two-dimensional, do you So it is O (N ^ 2)