counter = 0;
for (i=1; i<=n; i++)
if (a[i] == 1){
counter++;
}
else {
f (counter);
counter = 0;}
}
Let A[1, …, n] be an array storing a bit (1 or 0) at each location, and f(m) is a function whose time complexity is θ(m).
Then, What is the time complexity of this program fragment ?
I am stuck in the part that what will be the time complexity of function f(0),as it will be called continuously if array contains all the zeroes .