From 809c3ead196deebeb2188135851e718f0e2ce8fd Mon Sep 17 00:00:00 2001 From: Jerome Pui Date: Fri, 3 Jun 2022 21:48:35 +0800 Subject: [PATCH] contents: fix typos in hash table cheatsheet (#280) a data structure >>> is a data structure techniques in interviews, >>> techniques in interviews: Add full stop for open addressing --- contents/algorithms/hash-table.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contents/algorithms/hash-table.md b/contents/algorithms/hash-table.md index 3b153300..d7f784b3 100644 --- a/contents/algorithms/hash-table.md +++ b/contents/algorithms/hash-table.md @@ -21,14 +21,14 @@ toc_max_heading_level: 2 ## Introduction -A hash table (commonly referred to as hash map) a data structure that implements an associative array abstract data type, a structure that can map keys to values. A hash table uses a hash function on an element to compute an index, also called a hash code, into an array of buckets or slots, from which the desired value can be found. During lookup, the key is hashed and the resulting hash indicates where the corresponding value is stored. +A hash table (commonly referred to as hash map) is a data structure that implements an associative array abstract data type, a structure that can map keys to values. A hash table uses a hash function on an element to compute an index, also called a hash code, into an array of buckets or slots, from which the desired value can be found. During lookup, the key is hashed and the resulting hash indicates where the corresponding value is stored. Hashing is the most common example of a space-time tradeoff. Instead of linearly searching an array every time to determine if an element is present, which takes O(n) time, we can traverse the array once and hash all the elements into a hash table. Determining if the element is present is a simple matter of hashing the element and seeing if it exists in the hash table, which is O(1) on average. -In the case of hash collisions, there are a number of collision resolution techniques that can be used. You will unlikely be asked about details of collision resolution techniques in interviews, +In the case of hash collisions, there are a number of collision resolution techniques that can be used. You will unlikely be asked about details of collision resolution techniques in interviews: - **Separate chaining** - A linked list is used for each value, so that it stores all the collided items. -- **Open addressing** - All entry records are stored in the bucket array itself. When a new entry has to be inserted, the buckets are examined, starting with the hashed-to slot and proceeding in some probe sequence, until an unoccupied slot is found +- **Open addressing** - All entry records are stored in the bucket array itself. When a new entry has to be inserted, the buckets are examined, starting with the hashed-to slot and proceeding in some probe sequence, until an unoccupied slot is found. ## Learning resources