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

India - Water #21

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

India - Water #21

wants to merge 1 commit into from

Conversation

indiakato
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? A good hash function is important because you want to prevent as many collisions from happening as possible (mapping mostly unique keys to unique values).
How can you judge if a hash function is good or not? The hash function should have consistent mapping, have mostly unique keys mapping to unique values (low number of collisions), have constant look up time and hashing should appear random.
Is there a perfect hash function? If so what is it? No
Describe a strategy to handle collisions in a hash table Chaining - make each bucket of the hash table the head of a linked list.
Describe a situation where a hash table wouldn't be as useful as a binary search tree Binary search trees perform range searches more efficiently.
What is one thing that is more clear to you on hash tables now How to decide on a good hashing function in terms of the keys you use.

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 India, you hit the learning goals here. Well done.

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.

👍 Since you're sorting the strings, the time complexity is O(n + m log m) where m is the length of the words, but if you assume the strings are limited in size, you can say it's O(n).

Comment on lines +22 to 24
# Time Complexity: O(nlog(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.

👍

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