Skip to content

Conversation

paperbackwriter2
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important?
How can you judge if a hash function is good or not?
Is there a perfect hash function? If so what is it?
Describe a strategy to handle collisions in a hash table
Describe a situation where a hash table wouldn't be as useful as a binary search tree
What is one thing that is more clear to you on hash tables now

@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 some unused import statements, and your time complexity calculation for the anagrams problem. But, this shows sufficient demonstration of your knowledge of the material and that's good enough for a Green!

@@ -1,19 +1,43 @@

from ntpath import join
from sqlalchemy import true

Choose a reason for hiding this comment

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

Looks like these import statements never got used, so you can remove them to keep the code clean as a good style practice.

Space Complexity: ?
Time Complexity: O(n * m log m)
^ Not sure on the time complexity. Here, n represents the number of words in the
input string, while m represents the length of an individual word.

Choose a reason for hiding this comment

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

This is correct!

However, we can make a simplifying assumption. Since we know the words are English words and English words do not get too long (about 5 letters per word on average), the effect they have on this algorithm is dwarfed by the number of words in the list (which could easily get in the hundreds and thousands for a big list).

Thus, we can just say this is O(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