I am preparing for the exam, and for this I make some costs - when I come to the question, I'm a little unsure.
Question:

I am sure that the answer cannot be C or D, because the best run time for the code is O (1) and the worst run time is O (n).
I also think that B should be the correct answer, as the if-statement inside the forloop compares if A [i] == 0. What is the worst case of N.
What I'm not sure about when you call something “array access” and when is this a comparison? That is why I am not sure if the answer is B or A.
source
share