javascript-datastructures-algorithms icon indicating copy to clipboard operation
javascript-datastructures-algorithms copied to clipboard

wrong returned value in hash-table-linear-probing

Open Yamiqu opened this issue 2 years ago • 0 comments

https://github.com/loiane/javascript-datastructures-algorithms/blob/main/src/ts/data-structures/hash-table-linear-probing.ts#L45-L61

In the implementation of the get function, the returned value is not the correct index found by the while loop, instead of the original index. As a result, the first result will be returned instead of the expected one.

As follows

const test = new HashTableLinearProbing();

test.put('Jonathan', '5Jonathan');
test.put('Jamie','5Jamie')
test.put('Jack','7Jack');
test.put('Athelstan', '7Athelstan')

test.get('Jamie')  // =>  5Jonathan
test.get('Athelstan')  // => 7Jack

So I submitted a PR about fixing this problem. https://github.com/loiane/javascript-datastructures-algorithms/pull/207

Yamiqu avatar Aug 03 '22 18:08 Yamiqu