| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
hard Solved by 2 students
Time Complexity of ArrayList Removal
< Prev
Next >

What is the time complexity of the removeElements method shown below, where n is the number of elements initially in list?

public void removeElements(java.util.ArrayList<Integer> list) {
    while (!list.isEmpty()) {
        list.remove(0);
    }
}
A

O(log n)

B

O(n^2)

C

O(n)

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
#1thuyjerry01 0m 00s -10
#2turan.musayev.2807202001 0m 58s -68
#3zgj0731041703 1m 11s -101
#4lsj0803092235 9m 22s -282
Items per page:
10
1 – 4 of 4
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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