Skip to content

Conversation

@alexandria7
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 it ensures fast lookups (which is pretty much the point of using a hash table). If you don't have a good hash function, you could end up wasting time on lookups and increasing your time complexity.
How can you judge if a hash function is good or not? One way to judge if a hash function is 'good' or not is by the number of collisions it has and how it handles them, and also if it appears random. If a hash table has many collisions and implements chaining for handling them, then your lookup time will be pretty much like using a linked list (which is not really efficient).
Is there a perfect hash function? If so what is it? No there is not.
Describe a strategy to handle collisions in a hash table One way would be to implement chaining. If you have a collision (i.e. an element is attempted to be placed into a bucket where there is already an element), you can begin to chain your elements together in a linked list.
Describe a situation where a hash table wouldn't be as useful as a binary search tree You need unique keys to utilize a hash table - if you aren't going to be using unique keys, then a binary search tree might be more useful.
What is one thing that is more clear to you on hash tables now What they are under the hood!

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, including the top_k_frequent elements. Nice work You hit all the learning goals here.

# Each subarray will have strings which are anagrams of each other
# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(n * mlogm) where n is the length of the strings array and m is the length of each word

Choose a reason for hiding this comment

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

👍

# Space Complexity: ?
# Time Complexity: O(n) where n is the length of the list
# Space Complexity: O(n) where n is the length of the lists
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