Skip to content

Conversation

@Kimberly-Fasbender
Copy link

@Kimberly-Fasbender Kimberly-Fasbender commented Sep 17, 2019

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? It can mean the difference between a look up time of O(1) - constant, and O(n) - linear!
How can you judge if a hash function is good or not? You can check and see if it spreads similar elements randomly throughout the hash table, or if it clusters them in a close proximity to one another. You can also check to see if it creates a lot of collisions, or if it doesn't resize appropriately when it needs to.
Is there a perfect hash function? If so what is it? Yes, a hash function that maps a list of elements to a hash table with no collisions is considered perfect.
Describe a strategy to handle collisions in a hash table Linear probing - when there is a collision you go to the next bucket and see if it's empty. If it is you place the element there. If it is not, you continue until you find an empty bucket.
Describe a situation where a hash table wouldn't be as useful as a binary search tree Pretty much any time order matters. For instance, if you had a patient record and needed to be able to pull their min and max weights often.
What is one thing that is more clear to you on hash tables now The different strategies for handling collisions!

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.

Great work! You got the two methods here. Well done!

# Space Complexity: ?
# This method will return the k most common nums
# in the case of a tie it will select the first occuring num.
# Time Complexity: O(m * n) - where m is the value of k, and n is the length of the list

Choose a reason for hiding this comment

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

Exactly! Well done!

# Time Complexity: O(m * n log n) - where m is the length of the list, and n is the average length of a word in the list
# Space Complexity: O(n) - where n is the total amount of characters in list

def grouped_anagrams(strings)

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