Skip to content

Conversation

@evelynnkaplan
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? It helps avoid collision and keeps lookup time O(1).
How can you judge if a hash function is good or not? A hash function is good if it spreads values out evenly, if keys that are close in value get mapped to widely different values, if it can quickly calculate the mapped value for a key, and if it appears to be random.
Is there a perfect hash function? If so what is it? No.
Describe a strategy to handle collisions in a hash table Chaining - create a linked list where the first value mapped to an index will store the memory address of the next value that's mapped to that index, and so on.
Describe a situation where a hash table wouldn't be as useful as a binary search tree When order matters and you may need to be searching throughout the data set.
What is one thing that is more clear to you on hash tables now Various ways to resolve 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.

That will do it. Nice work.

# Each subarray will have strings which are anagrams of each other
# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(n) where n is the number of strings in the array.

Choose a reason for hiding this comment

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

Assuming the words are small yes. If the words can be of arbitrary size, you need to consider the time to sort the words.

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