logo

Crowdly

What is the worst-case time complexity of this function? Try to find the ti...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

What is the worst-case time complexity of this function?

  • Try to find the tightest upper bound you can.
  • Try to simplify as much as you can.
  • Even if your answer isn't the tightest upper bound/the most simplified, still write your attempt - there are partial marks.
  • Provide some reasoning for your answer (no explanation, no marks), and don't forget to define the variables you use.

def func(n):

    counter = 0

    i = 1

    while i <= n:

        for j in range(i):

            counter += 1

        i *= 2

    

    return counter

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на learning.monash.edu?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!