-
Notifications
You must be signed in to change notification settings - Fork 268
Graphs #163
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
Conversation
@TheSTL can you look into this? I am requesting a review from @igauravsehrawat as well! |
src/_DataStructures_/Set/index.js
Outdated
} | ||
|
||
union(givenSet) { | ||
const result = new Set(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be new XSet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup!
} | ||
|
||
// eslint-disable-next-line no-bitwise | ||
hashVal &= hashVal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this operation is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get a better hash. It may look useless but here is the explanation: https://stackoverflow.com/questions/38356644/why-is-the-bitwise-and-of-two-of-the-same-value-producing-a-different-value
I must update it in the comments as well
@@ -36,12 +36,14 @@ class HashTable { | |||
for (let i = 0; i < loopTill; i += 1) { | |||
const char = stringKey[i]; | |||
const value = char.charCodeAt(0) - 96; | |||
index = (index * PRIME_MULTIPLIER + value) % this.bucket.length; | |||
// eslint-disable-next-line no-bitwise | |||
index &= index; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this operation is required?
hashVal += PRIME_ADDER; | ||
} | ||
// eslint-disable-next-line no-bitwise | ||
hashVal &= hashVal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this operation is required?
🕸 What's Inside?
A simple implementation of Graphs using the Adjacency List using Singly Linked List and Object
Having the following APIs:
Changes: