Skip to content

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

Merged
merged 6 commits into from
Apr 28, 2020
Merged

Graphs #163

merged 6 commits into from
Apr 28, 2020

Conversation

ashokdey
Copy link
Member

@ashokdey ashokdey commented Dec 10, 2019

🕸 What's Inside?

  • A simple implementation of Graphs using the Adjacency List using Singly Linked List and Object

  • Having the following APIs:

    • addVertex(v)
    • removeVertex(v)
    • addEdge(v, e)
    • removeEdge(v, e)
    • getEdges(v)
    • display()

Changes:

  • Added filter(value) method for Singly Linked List

@ashokdey
Copy link
Member Author

@TheSTL can you look into this? I am requesting a review from @igauravsehrawat as well!

@ashokdey ashokdey self-assigned this Apr 26, 2020
}

union(givenSet) {
const result = new Set();
Copy link
Member

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

Copy link
Member Author

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;
Copy link
Member

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?

Copy link
Member Author

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;
Copy link
Member

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;
Copy link
Member

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?

@ashokdey ashokdey merged commit d4791c0 into master Apr 28, 2020
@ashokdey ashokdey deleted the graphs branch April 28, 2020 03:38
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