Skip to content

Conversation

@seaweeddol
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? Hash functions can perform searches quickly
How can you judge if a hash function is good or not? A good hash function should be consistent and map different keys to different values.
Is there a perfect hash function? If so what is it? No
Describe a strategy to handle collisions in a hash table One way is to use a linked list (chaining). Even if there is a collision, linked lists are quick to insert and remove items as long as there aren't too many elements.
Describe a situation where a hash table wouldn't be as useful as a binary search tree If you cannot provide unique key values then a hash table is not the best choice.
What is one thing that is more clear to you on hash tables now Different methods of collision handling

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.

Well done Jessica, you hit the learning goals here Nice work.

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

# hash function that assigns each letter a value
def alphabet_keys()

Choose a reason for hiding this comment

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

Nice helper!

return alphabet_keys
end

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 +49 to 51
# 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.

👍

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