01 / 17

What is the average and worst-case time complexity for lookup in a Hash Table?

Hash Table Complexity

javascript
  1. 1

    Average-case lookup: expected O(1).

  2. 2

    Worst-case lookup: O(n) for a conventional chained or open-addressed table.

  3. 3

    Performance depends on hash quality, load factor, collision strategy, and implementation.

  4. 4

    Resizing helps maintain the expected constant-time behavior.

  5. 5

    Some modern implementations can improve pathological bucket behavior to O(log n) using balanced trees.

Difficulty: 2/10

Follow-up Questions

  • Why can lookup become O(n)?
  • How can implementations improve the worst case?