Function with count

1
2
3
4
5
6
7
count=0
for i in range(1, n+1):
    if (A[i] == 1):
        count+=1
     else:
        f(count)
        count=0
  • \(A[1\cdots n]\) in the code snippet above is an array of number(s) containing either 0 or 1 at each place.

  • \(f(x)\) is a function whose time complexity is \(\Theta(x)\).

What is the time complexity of the code snippet?

×

Problem Loading...

Note Loading...

Set Loading...