Question Bank

Big-O Complexity Quiz

Difficulty: Easy

Four short prompts on identifying time complexity from JavaScript code: nested loops, halving, recursion, and a bug-by-complexity hunt.

Question Bank
/

Big-O Complexity Quiz

Big-O Complexity Quiz

Four short prompts on identifying time complexity from JavaScript code: nested loops, halving, recursion, and a bug-by-complexity hunt.

Question Bank
Easy
JavaScript
4 questions
big-o
asymptotic-analysis
quiz
fundamentals

1,137 views

11

What is the time complexity of this function and why?

Examples

Example 1:

Input: f(3)
Output: inner body executes 3 * 3 = 9 times
Explanation: Two nested loops over n give n^2 iterations. f(6) runs 36 iterations, confirming the quadratic shape. Time O(n^2), space O(1).