javascript-datastructures-algorithms
javascript-datastructures-algorithms copied to clipboard
wrong returned value in hash-table-linear-probing
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