Are you taking CLEP classes? Try clep.ai
| 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

Mark
< Prev
Next >

Consider the following method. What is its time complexity?

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(n)

B

O(n^2)

C

O(n log n)

D

O(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.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|