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

Daniela - Leaves #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Daniela - Leaves #36

wants to merge 3 commits into from

Conversation

dnsanche
Copy link

@dnsanche dnsanche commented Mar 12, 2020

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? A good hash function has few collisions and it makes easy to look elements.
How can you judge if a hash function is good or not? By how the elements are converted to binary. If a lot of elements are in the same cluster, it will create collisions.
Is there a perfect hash function? If so what is it? No. There is no magic recipe.
Describe a strategy to handle collisions in a hash table
Describe a situation where a hash table wouldn't be as useful as a binary search tree
What is one thing that is more clear to you on hash tables now

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.

You didn't attempt the comprehension questions!

You did get grouped_anagrams method working. Take a look at my comments about bigO for my comments there. Missing kth most frequent elements, but what you have is well done.

lib/exercises.rb Outdated
Comment on lines 5 to 11
# Time Complexity: n^2 as for each word in the list I'm iterating over the letters.

# # Space Complexity: O(n) because if none of the words are anagrams,
# I will duplicate the array. Also, I will create a hash were each key is each word.


def grouped_anagrams(strings)

Choose a reason for hiding this comment

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

This is actually O(n * m) where m is the length of the strings. Or O(n) if the words are limited in size.

Good use of a hash as a key to another hash!

@dnsanche
Copy link
Author

@CheezItMan I just submitted my second exercise. Can you review it when you have a chance? I would appreciate your feedback. TY!!

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.

Nice work Daniela, these both work. Well done.

end
# Time Complexity: O(kn)
# Space Complexity: O(n)
def top_k_frequent_elements(list, k)

Choose a reason for hiding this comment

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

This works

Comment on lines +4 to +7
# Time Complexity: O(n * m) as for each word in the list I'm iterating over the letters.
# # Space Complexity: O(n).

def grouped_anagrams(strings)
raise NotImplementedError, "Method hasn't been implemented yet!"
def grouped_anagrams(list_strings)

Choose a reason for hiding this comment

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

👍
Nice work!

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