Skip to content

Nourhan - Spruce - C16#54

Open
Nourhan21 wants to merge 1 commit intoAda-C16:masterfrom
Nourhan21:master
Open

Nourhan - Spruce - C16#54
Nourhan21 wants to merge 1 commit intoAda-C16:masterfrom
Nourhan21:master

Conversation

@Nourhan21
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 had some comments about your time complexity calculation for the anagrams problem and an unused import statement, but overall this looks good enough for a Green.

Each subarray will have strings which are anagrams of each other
Time Complexity: ?
Space Complexity: ?
Time Complexity: O(nlog(n))

Choose a reason for hiding this comment

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

My guess is that you noticed your call to sorted and are accounting for that, with n referring to the number of characters in the strings (as that's what affects how long sorted takes).

However, don't forget about the number of strings in the list (let's call that m), which will call sorted each time for O(m * n * log(n)).

But the good news is that we can actually make a simplifying assumption! Since we know the strings are English words, and English words tend to be limited in length (about 5 letters on average), the effect of n is going to be dwarfed by m, the number of strings in strings. There may be hundreds or thousands of strings in strings, after all. With that we can give the time complexity as O(n).

@@ -1,19 +1,45 @@

from typing import OrderedDict

Choose a reason for hiding this comment

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

Looks like this import statement never got used. In general, just to keep the code clean, you probably want to remove unused imports like these.

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