🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)

  1. A.Reading arr[i] from an array
  2. B.Checking if a key exists in a hash map
  3. C.Checking x in my_list for a Python list
  4. 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 →