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

Arcila Maple C16 #52

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

Arcila Maple C16 #52

wants to merge 1 commit into from

Conversation

arcila13
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? you can prevent too many collisions
How can you judge if a hash function is good or not? if it avoids as many collisions as possible
Is there a perfect hash function? If so what is it? No
Describe a strategy to handle collisions in a hash table Chaining: each element of a hash table's internal array serves as the head of a linked list. This allows the same bucket to store multiple items.
Describe a situation where a hash table wouldn't be as useful as a binary search tree if you need to insert or update data
What is one thing that is more clear to you on hash tables now Collisions, why they occur and how to handle them.

@chimerror
Copy link

Grabbing this to grade!

Copy link

@chimerror chimerror left a comment

Choose a reason for hiding this comment

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

Good work!

I added some comments about extraneous comments and your time complexity calculation for the Top-K problem, but otherwise this looks good enough for a Green.

# ["ate","eat","tea"],
# ["nat","tan"],
# ["bat"]
# ]

Choose a reason for hiding this comment

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

As a style thing, you'll usually want to remove comments like this that are not really related to explaining why the code is designed a certain way.



# Input: nums = [1,1,1,2,2,3], k = 2
# Output: [1,2]

Choose a reason for hiding this comment

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

Same as above, you can probably remove comments like these after they've helped you write your code.

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

Choose a reason for hiding this comment

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

Don't forget to account for the call to sorted, which takes O(n * log(n)) time, and thus dominates the O(n) part of this algorithm giving a final time complexity of O(n * log(n)).

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