Skip to content

Conversation

@msfinnan
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 to get O(1) lookup time
How can you judge if a hash function is good or not? A good hash function has values spread out throughout the array
Is there a perfect hash function? If so what is it? No
Describe a strategy to handle collisions in a hash table create a linked list of values at index, check for next available free space, create an algorithm to find the next available space
Describe a situation where a hash table wouldn't be as useful as a binary search tree A binary search tree would be better in a situation where you do not necessarily have unique keys
What is one thing that is more clear to you on hash tables now handling 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.

Nice work, you hit the main learning goals here. Check out my feedback and let me know if you have questions.

end
end

hash.sort_by { |k, v| v }

Choose a reason for hiding this comment

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

Clever!, but what does this do to the time complexity?

# in the case of a tie it will select the first occuring element.
# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(n)

Choose a reason for hiding this comment

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

You're doing sorting in this solution... How does that impact time complexity?

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