Skip to main content
1 of 2
owwyess
  • 145
  • 1
  • 1
  • 8

Asymptotic running time of for-loops

I have this question which I need answered: enter image description here

And the correct result is "B: Linear in N" which I can't figure out why, since that as far as I've understood, we want to accept the worst case>best case. The worst case here is that the if statement is run and the time would then be quadractic in N. I am aware that we're trying to find some kind of average of more attempts, but how can I know what the value of N is? If N is really high (10000), it's obviously the else statement that is run most of the times. But can we assume this or have I misunderstood something? Thanks in advance.

owwyess
  • 145
  • 1
  • 1
  • 8