| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
hard
Nested Loop Time Complexity
< Prev
Next >

Determine the overall time complexity of the nestedDoublingLoop method.

public void nestedDoublingLoop(int n) {
    for (int i = 1; i < n; i *= 2) {
        for (int j = 0; j < i; j++) {
            System.out.println(i + j);
        }
    }
}
A

O(log n)

B

O(n^2)

C

O(n)

D

O(n log n)

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy