diff --git a/apps/docs/content/(01-linear-structures)/hash-table/index.mdx b/apps/docs/content/(01-linear-structures)/hash-table/index.mdx index 0f6f791..2b720f4 100644 --- a/apps/docs/content/(01-linear-structures)/hash-table/index.mdx +++ b/apps/docs/content/(01-linear-structures)/hash-table/index.mdx @@ -4,8 +4,6 @@ description: 'A key maps to a value in constant time, which removes the need for hidden: true --- -## Hash Tables - Sometimes when programming, we need a data structure that maps an arbitrary data type to another arbitrary data type, like an array with non-integer indices. For example, a phone book that allows lookup by a person's name requires such data type. A **hash table** (or a hash map) is one way of representing this data structure. The idea of hash table is this: @@ -14,7 +12,9 @@ Data is stored in a fix-sized array, where each data value has an unique index. - Hash Table Operations + +![](../../../public/hash-table-operations.svg) + @@ -22,7 +22,7 @@ Data is stored in a fix-sized array, where each data value has an unique index. Assuming the hash function uses constant time, the average time complexity is `O(n / k)` for each insertion/access operation on the table, where `n` is the number of entries in the hash table and `k` is the array size of the table. This assumes the hash function distributes keys uniformly across the `k` buckets, so each bucket holds about `n / k` entries on average. -**Frequency Counting** +### Frequency Counting ```python def get_counter(arr: list[int]) -> dict[int, int]: