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

Leaves - Mariya #38

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

Leaves - Mariya #38

wants to merge 2 commits into from

Conversation

M-Burr
Copy link

@M-Burr M-Burr commented Mar 12, 2020

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? It enables faster look-up times and reduces collusions
How can you judge if a hash function is good or not? It should map different keys to different values & indexing should appear random. A good hash function should also be fast.
Is there a perfect hash function? If so what is it? There is no perfect hash function.
Describe a strategy to handle collisions in a hash table chaining with linked list
Describe a situation where a hash table wouldn't be as useful as a binary search tree when elements need to be sorted
What is one thing that is more clear to you on hash tables now how collusions are prevented

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 hit the main learning goals here. Take a look at my inline comments and let me know what questions you have. Well done.

Comment on lines +5 to 8
# Time Complexity: O(n)
# Space Complexity: O(n)

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 works and assuming the words are small you are right on the time/space complexity.

end
end

values_sort = counter_hash.sort_by {|key, value| -value}

Choose a reason for hiding this comment

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

This sort depends on the number of distinct elements, so it's worst-case O(n log n)

Comment on lines +25 to 27
# Time Complexity: O(n)
# 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, but take a look at my comments on big O.

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