Loop and Recursion Time Complexity
What is the time complexity of the following combinedMethod method?
public void combinedMethod(int n) {
if (n <= 1) return;
for (int i = 0; i < n; i++) {
System.out.println(i);
}
combinedMethod(n - 1);
}
A
O(n log n)
B
O(n^2)
C
O(n)
D
O(2^n)
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE