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

Water - Beatrice #32

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

Water - Beatrice #32

wants to merge 2 commits into from

Conversation

Beatress
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? To minimize collisions
How can you judge if a hash function is good or not? It is consistent, random, doesn't collide much, and runs in constant time
Is there a perfect hash function? If so what is it? There isn't a perfect one
Describe a strategy to handle collisions in a hash table You can do chaining, where each bucket is a linked list or array. You can also do probing, where an equation takes you from one bucket to the next
Describe a situation where a hash table wouldn't be as useful as a binary search tree If we frequently need to search
What is one thing that is more clear to you on hash tables now How they work internally

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 Beatrice, this is well done.

Comment on lines +4 to 9
# Time Complexity: O(n) where n is number of strings
# O(n) to build strings_map, O(n) to build reverse_map, O(n) to build answer_array
# Space Complexity: O(n) where n is number of strings
# While there is a large amount of data structures, they scale linearly

def grouped_anagrams(strings)

Choose a reason for hiding this comment

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

👍

Comment on lines +44 to 47
# Time Complexity: O(n log n) - O(n) to build map, O(n) to reverse,
# O(n log n) to sort, O(n) to find answer where n is amount of numbers
# Space Complexity: O(n) - Similarly to last time, there's a decent overhead but it scales linearly
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.

👍 Nice work, correct on time/space complexity as well.

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