Home > Back-end >  How to ask time complexity?
How to ask time complexity?

Time:11-05

The teacher gave such a topic, I mainly want to ask the if and the else? If the if that is not executed once set up? That is if the else set up n take one? Is that for and x++ alone?
I also want to poke fun at this software no problem, on baidu baidu let me open this software but after open search less than what I am looking for (humble)

CodePudding user response:

Perform how many ah, how many times is n time is O (n)

CodePudding user response:

If the if, once, if if fails, n time,
If set up or not as a random event, that is, 50%, 50%,
So the whole algorithm time expectations of T (n)=1 + n * 0.5 * 0.5=0.5 + 0.5 n
When n - & gt; Up, T (n)/n - & gt; The limited number of 0,
So the algorithm time complexity can be understood as roughly O (n)
  • Related