Time complexity of a function f(m) is O(m). If the array[i...n] > contains either 1 or 0 in each of it's locations, determine the worst > case time complexity of the following piece of code written in C-like > language. > > counter=0; > for(i=0; i=n; i++){ > if(a[i]==1) > counter++; > else{ > f(counter); > counter=0; > > } > } > > * i=n was given in the condition of for loop > > a) O(n^2) > b) O(n^2 logn) > c) O(nlogn) > d) O(n)

AnswerBot
1y

Determining worst case time complexity of a code snippet with given time complexity of a function and array

  • The time complexity of the given code snippet is O(n)

  • The function f(m) is called only when a ...read more

Help your peers!
Add answer anonymously...
Microsoft Corporation Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter