Skip to content

Conversation

cyndilopez
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

PS: I worked on the sudoku problem for quite awhile, but I was doing it on an online repl because I only had my work laptop. That repl somehow disappeared and I can't recover it, so sorry that this doesn't include that problem. I was a little too frustrated to re-create my work, but I have learned my lesson on using repls.

Question Answer
Why is a good Hash Function Important?
How can you judge if a hash function is good or not? It's fast, it's output of indices is uniform; it's consistent; and output appears to be random; values that are close together are located far away from each other in the hash
Is there a perfect hash function? If so what is it? no?
Describe a strategy to handle collisions in a hash table in linear probing, if two values output from a hash are in the same bucket, it is checked if the spot adjacent to the bucket is empty; if it is, it is placed there, otherwise an empty bucket continues to be searched for until the one is found
Describe a situation where a hash table wouldn't be as useful as a binary search tree if order matters
What is one thing that is more clear to you on hash tables now behind the scenes how a hash table works

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.

You did solve the problem. Is this the most efficient solution?

# Time Complexity: ?
# Space Complexity: ?

def grouped_anagrams(strings)

Choose a reason for hiding this comment

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

This definitely works, but what is the time/space complexity.

Also could you do this more efficiently with a hash?

matched = false
array_store_anagrams.length.times do |j|
array = array_store_anagrams[j]
if array[0].split("").sort.join == strings[i].split("").sort.join

Choose a reason for hiding this comment

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

You're sorting both sides here... maybe this could be opimized...

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