← Time & Space Complexity Quiz: all 8 questions
Time & Space Complexity Quiz · Question 6 of 8
Which operations are O(1) on average? (select all that apply)
Which operations are O(1) on average? (select all that apply)
- A.Reading
arr[i]from an array - B.Checking if a key exists in a hash map
- C.Checking
x in my_listfor a Python list - D.Sorting an array
Answer & explanation
Correct answer: Reading arr[i] from an array · Checking if a key exists in a hash map
Index access and hash lookups are constant time on average. Searching a list scans it (O(n)); sorting is O(n log n).
Can you get the rest right without peeking?
Take the timed Time & Space Complexity Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →