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

Liv - Space #32

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

Liv - Space #32

wants to merge 4 commits into from

Conversation

mulhoo
Copy link

@mulhoo mulhoo commented Sep 30, 2020

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? When it's "ideal" it has a time complexity of O1 for insert/delete/search. Makes it faster than a lot of other structures.
How can you judge if a hash function is good or not? if the hash values are uniformly distributed, close keys have far apart values, hashing appears to be random
Is there a perfect hash function? If so what is it? Yes, where there is one-to-one mapping from each key to a unique integer value
Describe a strategy to handle collisions in a hash table Separate chaining - using a linked list to store the collided keys, but uses additional memory
Describe a situation where a hash table wouldn't be as useful as a binary search tree Anywhere you need to find ordered data.
What is one thing that is more clear to you on hash tables now Why they are the best choice for certain scenarios

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.

I like your solution for the Anagram problem, the solution for the k most frequent elements isn't quite working, but think about making a hash where the keys are the elements and the values are their frequencies. That might get you started here.

Comment on lines +3 to 6
# Time Complexity: On
# Space Complexity: On

def grouped_anagrams(strings)

Choose a reason for hiding this comment

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

Clever, I like the use of a subhash as a key.

Comment on lines +24 to 26
# Time Complexity: On
# Space Complexity: On
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.

Not quite working as it fails for [3, 3, 3, 3, 3, 1, 1, 2, 2, 2]

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