Хеш-таблица

Хранилище ключ-значение с поиском O(1) через хеш-функцию.

A hash table (or hash map) is a structure that can map keys to values. A hash table uses a hash [function](/ru/terms/hash-function) to compute an index into an array of buckets or slots, from which the desired value can be found. In an ideal case, the hash function will assign each key to a unique bucket, but most hash table designs employ some form of collision resolution.

        graph LR
  Center["Хеш-таблица"]:::main
  Rel_index_database["index-database"]:::related -.-> Center
  click Rel_index_database "/terms/index-database"
  Rel_relational_database["relational-database"]:::related -.-> Center
  click Rel_relational_database "/terms/relational-database"
  Rel_object["object"]:::related -.-> Center
  click Rel_object "/terms/object"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 Проверка знаний

1 / 1

🧒 Простыми словами

Представь гардероб. Ты сдаешь куртку и получаешь номерок. Чтобы забрать, даешь номер, и гардеробщик идет сразу к нужному месту. Хеш-таблицы вычисляют этот 'номерок' из твоего ключа!

🤓 Expert Deep Dive

Идеальное хеширование (Perfect hashing). Cuckoo hashing гарантирует O(1) поиск. Robin Hood hashing уменьшает дисперсию. Consistent hashing минимизирует ремаппинг в распределенных системах. Фильтры Блума.

📚 Источники