144k views
3 votes
What is the tightest complexity of the following code segment? for (i=0;i(a) O(n)

(b) O(logn)
(c) O(n²)
(d) O(nlogn)
(e) O(n³)

User Jelle Foks
by
8.3k points

1 Answer

1 vote

Final answer:

The tightest complexity of the code segment is O(n).

Step-by-step explanation:

The tightest complexity of the given code segment can be determined by analyzing the number of iterations the loop will undergo. The loop iterates from i = 0 until i < n, incrementing i by 1 in each iteration. Therefore, the loop will execute for a total of n times. In big O notation, this can be represented as O(n).

User Arun Pal
by
7.5k points