Home > Back-end >  O time complexity
O time complexity

Time:09-18

i=1; k=0; N=100;
Do {
K=k + 10 * I;
i=i++;
}while(i!=n);
The examination paper answer is O (1);
Great god to explain;

CodePudding user response:

Linear is o (1)

CodePudding user response:

Although cycles is n - 1, is also a linear function of n, it should be O (n)

CodePudding user response:

Corresponding to the array subscript directly take an array element that is O (1)?

CodePudding user response:

I think it is O (n), the examination paper answer is not correct
  • Related