πŸ“’ Too many exams? Don’t know which one suits you best? Book Your Free Expert πŸ‘‰ call Now!

  • google app store apple app store
  • βœ–

      Question

      Python's built-in dict (dictionary) data structure is

      typically implemented using a hash table. What is the average-case time complexity for get, set, and del operations in a Python dictionary?
      A O(N) Correct Answer Incorrect Answer
      B O(log N) Correct Answer Incorrect Answer
      C O(1) Correct Answer Incorrect Answer
      D O(N log N) Correct Answer Incorrect Answer
      E O(N^2) Correct Answer Incorrect Answer

      Solution

      Python's dict is implemented as a hash table. On average, operations like get, set (insertion/update), and del (deletion) have a constant time complexity, O(1), assuming a good hash function and effective collision resolution.

      Practice Next
      ask-question