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

Jessica #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Jessica #1

wants to merge 1 commit into from

Conversation

jessicacaley
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? It allows an even distribution within the hash and helps avoid collisions, which keeps lookup at constant time instead of O(n).
How can you judge if a hash function is good or not? The hash is evenly distributed and seems random.
Is there a perfect hash function? If so what is it? No.
Describe a strategy to handle collisions in a hash table One strategy is to make a linked list of the collision key/value pairs at the collision location.
Describe a situation where a hash table wouldn't be as useful as a binary search tree If a traversal would be helpful for any reason.
What is one thing that is more clear to you on hash tables now I feel more clear about how lookup works when collisions occur (it helped to understand that the worst case is actually O(n) for any (poorly implemented) solution, just like going through an array).

@jessicacaley jessicacaley changed the title implement all exercises (tests pass) Jessica Sep 12, 2019
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, your Sudoku method could use a bit of drying up, but it all works. You even did the kth common elements as well. Nice work.

Take a look at my comments and let me know what questions you have.

# Time Complexity: ?
# Space Complexity: ?

# Time Complexity: O(n logn) where n is the length of the strings in the strings element

Choose a reason for hiding this comment

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

I would say that it's O(n) where n is the number of strings if the length of any particular string is pretty small.

It's O(n m log m) where n is the number of strings and m is the average length of any particular string, if the strings can be arbitrarily large.

# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(n) where n is the length of list
# Space Complexity: O(n) where n is the length of the list
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.

👍

second_subgrid = {}
third_subgrid = {}

table[0..2].each do |row|

Choose a reason for hiding this comment

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

This looks pretty repetitive, could you instead create a method to do this on different subgrids?

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