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

Alex #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Alex #5

wants to merge 2 commits into from

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!

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
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.

@@ -2,29 +2,72 @@

# This method will return an array of arrays.
# 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.

👍

# Time Complexity: ?
# 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.

None yet

2 participants