Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

What is the time complexity of checking membership with 'in' on a set?

  1. A O(n)
  2. B O(log n)
  3. C O(1) on average
  4. D O(n log n)
Answer

O(1) on average

Sets use a hash table. Replacing a list membership test inside a loop with a set is a common fix for accidentally quadratic code.

All Python MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as