Skip to content

Conversation

@aliceboone
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? Its a data structure used to get the data we need in a faster way.
How can you judge if a hash function is good or not? It can be highly efficient and distribute the keys uniformly
Is there a perfect hash function? If so what is it? Where that has no collisions
Describe a strategy to handle collisions in a hash table One strategy is using separate chaining
Describe a situation where a hash table wouldn't be as useful as a binary search tree Balanced BST would be preferred because of their lower computing cost when a table needs resizing
What is one thing that is more clear to you on hash tables now There is a lot of options to solve collision.

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 Alice, you hit the main learning goals. I did have some comments on time complexity. Let me know if you have any questions regarding it.

Comment on lines +4 to 7
# 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.

👍 The time complexity is O(n) if the strings are limited in size, if they're not because you're sorting the time complexity is O(m * n log n), where m is the number of strings and n is the length of the strings.

Comment on lines +26 to 28
# 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.

👍 However, because you're sorting the time complexity is O(n log n)

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