| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice TestPractice Test
About Exam
medium Solved by 8 students
Recursive Method Time Complexity
< Prev
Next >

What is the worst-case time complexity of the tail-recursive tailSum method shown below?

public int tailSum(int[] arr, int index, int acc) {
    if(index == arr.length) return acc;
    return tailSum(arr, index + 1, acc + arr[index]);
}
A

O(log n)

B

O(n)

C

O(n^2)

D

O(1)

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1singhris00011 0m 23s 77
#2tellabhinaya11 1m 31s 9
#3ethan13 1m 52s -32
#4gorkemakyuz20107511 3m 06s -86
#5suhanakochhar00614 6m 22s -312
#6richa.tuli12 9m 10s -460
Items per page:
10
1 – 6 of 6
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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