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

Time - Denisse #24

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

Time - Denisse #24

wants to merge 3 commits into from

Conversation

denisseai
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? Because we need data to be found fast and without problems
How can you judge if a hash function is good or not? It should be efficiently computable and it should distribute the keys uniformly
Is there a perfect hash function? If so what is it? One that has no collisions
Describe a strategy to handle collisions in a hash table One collision resolution strategy is using separate chaining
Describe a situation where a hash table wouldn't be as useful as a binary search tree Balanced BST would be preferred because of their lower computing cost when a table needs resizing
What is one thing that is more clear to you on hash tables now There are more than 1 way to resolve 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.

Overall well done. You do need more practice looking at things in terms of time/space complexity. It's ok to guess at the answers here and state your reasoning. I can give you feedback then.

lib/exercises.rb Outdated Show resolved Hide resolved
lib/exercises.rb Outdated Show resolved Hide resolved
Comment on lines +4 to 7
# Time Complexity: a lot
# Space Complexity: O(n)

def grouped_anagrams(strings)

Choose a reason for hiding this comment

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

Time complexity 🤣

It's actually O(n) assuming the words are reasonably short O(n * mlog m) otherwise.

Comment on lines 31 to 34
# Time Complexity: ?
# Space Complexity: ?
# resource: https://stackoverflow.com/questions/4264133/descending-sort-by-value-of-a-hash-in-ruby
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.

Good that you cited your source. Time & space complexity?

denisseai and others added 2 commits September 24, 2020 20:06
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