Let A be an array[1..n] which has zeros and ones in it.and func() be function whose complexity is theta(m).For the given pseudo code what would be the complexity?
counter=0;
for(i=0;i<n;i++)
{
if(a[i]==1)
counter++;
else
func();
}
Accorlding to me the worst case for the function func() to be called at most n times would be when the arrays are completly filled with zeroes . Hence as the theta noation of func() is given as theta(m)
The complexity for the above code would be :theta(mn) ....??? If no,please help me with a proper validation.