Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong returned value in hash-table-linear-probing #208

Closed
Yamiqu opened this issue Aug 3, 2022 · 0 comments
Closed

wrong returned value in hash-table-linear-probing #208

Yamiqu opened this issue Aug 3, 2022 · 0 comments

Comments

@Yamiqu
Copy link
Contributor

Yamiqu commented Aug 3, 2022

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. #207

@Yamiqu Yamiqu closed this as completed Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant