logo

Question detail

Consider this Python 3 code: for item in data: print(item) What is the time complexity in terms of the number of items, n?

Try the question, check the answer, then read the explanation to understand the curriculum point.

At a glance

MCQ

Type

practice

Style

Topic

Classification of algorithms

Exam-style question

Try this first

Consider this Python 3 code: for item in data: print(item) What is the time complexity in terms of the number of items, n?.

  1. A.O(1)
  2. B.O(log n)
  3. C.O(n)
  4. D.O(n^2)

Model answer

What a good answer should say

  • O(n)

Explanation

Why this works

The loop executes once for each item in data. Therefore, the number of operations grows in direct proportion to n.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.