Apr 1, 2021
Hello,
The process is the following:
- Calculate hash code: in this simplified example we assume that it’s 2.
- Calculate bucket index based on the index: it’s 2%2 = 0.
- Lookup the head index in hashTable: 0 in this case.
- Iterate over the linked list stored in dataTable starting with index 0until the key is found: we’re going to start with <0, ‘a’> item (index 0) and then iterate to <2, ‘c’>(index 2).
- Return the key, if found, or undefined otherwise.
Hopefully, this makes sense.