Home > Back-end >  Data structure and time complexity
Data structure and time complexity

Time:11-11

Trouble, have a look at the problem and the answer is what TAT

please?

CodePudding user response:

N * log2n

CodePudding user response:

O (n)
Outer loop meaningless, memory cycle, not necessarily meet the outer loop condition, so the time complexity of time complexity is the inner loop, the inner loop is 1 to n cycle, there is n times, so is O (n)

CodePudding user response:

Of course, a prerequisite is the outcome of the I * 2 shall not exceed the scope of int, otherwise possible infinite loop,
  • Related