docs(content): improve hash table page formatting and headings

This commit is contained in:
Prad Nukala committed 2026-10-01 16:51:07 -04:00
1 parent 9899813281
commit 017f111594
1 file changed
+4 -4
@@ -4,8 +4,6 @@ description: 'A key maps to a value in constant time, which removes the need for
hidden: true 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. 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: 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.
<Frame caption="Hash Table Operations"> <Frame caption="Hash Table Operations">
<img src="../../../public/hash-table-operations.svg" alt="Hash Table Operations" />
![](../../../public/hash-table-operations.svg)
</Frame> </Frame>
@@ -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. 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 ```python
def get_counter(arr: list[int]) -> dict[int, int]: def get_counter(arr: list[int]) -> dict[int, int]: