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

Amy W #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Amy W #3

wants to merge 1 commit into from

Conversation

amythetester
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? You get the O(1) lookup benefits.
How can you judge if a hash function is good or not? If the keys are not grouped close together, it does not have a lot of collisions, the keys that are produced are as unique as possible.
Is there a perfect hash function? If so what is it? Technically yes, but it's really hard to do. This would be if there are not collisions so each unique key only has one value.
Describe a strategy to handle collisions in a hash table You can have an overflow data structure like an array or linked list or you can probe for an empty space in the table.
Describe a situation where a hash table wouldn't be as useful as a binary search tree If the hash function is not a good one and all of the keys end up being the same, effectively creating a linked list. Cases where the data is sortable, but not hash friendly.
What is one thing that is more clear to you on hash tables now How the hash function can work. :)

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Well done.

// Space Complexity: ?
function grouped_anagrams(strings) {
throw new Error("Method hasn't been implemented yet!");
// Time Complexity: O(n) where n is the length of the input array

Choose a reason for hiding this comment

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

Since you're sorting the strings this would be O(n * m log m) where m is the average length of a string. If you can assume the strings are small, you can drop the m term.

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

Successfully merging this pull request may close these issues.

2 participants