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

added Hash Table #160

Merged
merged 13 commits into from
Dec 1, 2019
Merged

added Hash Table #160

merged 13 commits into from
Dec 1, 2019

Conversation

ashokdey
Copy link
Member

@ashokdey ashokdey commented Nov 29, 2019

🌮 What's Inside?

Added the most extensively used Data Structure - Hash Tables (aka Hash Map)

API Details:

  • set(key, value): to set the key-value pair
  • get(key): to get the value(s) associated with the given key
  • delete(key): remove the key and the associated values

Note: Passing the same key with different value, overrides the previous value

🏖

@TheSTL
Copy link
Member

TheSTL commented Nov 30, 2019

In remove method instead of creating whole new linked list, manipulating the existing one will be a better approach i think because old linked list will remain in memory. @ashokdey

@ashokdey
Copy link
Member Author

In remove method instead of creating whole new linked list, manipulating the existing one will be a better approach i think because old linked list will remain in memory. @ashokdey

@TheSTL raise a PR with this branch for the same

@ashokdey
Copy link
Member Author

In remove method instead of creating whole new linked list, manipulating the existing one will be a better approach i think because old linked list will remain in memory. @ashokdey

I've updated it but would like to see your approach as well 👍

@TheSTL
Copy link
Member

TheSTL commented Nov 30, 2019

@ashokdey get function returns an array. I'm not able to understand why? It should return the value

@ashokdey
Copy link
Member Author

ashokdey commented Dec 1, 2019

@ashokdey get function returns an array. I'm not able to understand why? It should return the value

Because I am not able to finalize either to override a value when the same key is used more than once. For example:

ht.set('hello', 'Hello Hash Table');
ht.set('hello', 'Hello World');

I am willing to go with override

Copy link
Member

@TheSTL TheSTL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@TheSTL TheSTL merged commit 094e1ba into master Dec 1, 2019
@ashokdey ashokdey deleted the hash-table branch December 4, 2019 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants