Multiple choice technology

What is the running time of the code written below. myfn(int n) if n<1 then return

  1. O(n)

  2. O(n2)

  3. O(nlgn)

  4. O(n2lgn)

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The recursive function shown has a pattern that suggests nested loops leading to O(n²) complexity. For each of n iterations, there are up to n recursive calls or operations within, giving quadratic time complexity. O(n²) is a common complexity for nested iteration patterns.