Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
ashokdey merged 6 commits into master from graphs
Apr 28, 2020
Merged

Graphs #163

ashokdey merged 6 commits into master from graphs
Apr 28, 2020

Conversation

Copy link
Member

@ashokdey ashokdey commented Dec 10, 2019
edited
Loading

🕸 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

Copy link
Member Author

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

}

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?

ashokdey reacted with thumbs up emoji
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
Reviewers

@TheSTL TheSTL TheSTL approved these changes

@igauravsehrawat igauravsehrawat Awaiting requested review from igauravsehrawat

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /