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

Branches- Amal #2

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

Branches- Amal #2

wants to merge 1 commit into from

Conversation

ashassan
Copy link

@ashassan ashassan commented Mar 9, 2020

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? it will have a better runtime because there will be fewer collisions
How can you judge if a hash function is good or not? it does fast computation of the hash, hash keys are distributed, and you can not figure out the original object
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 use chaining which is when you store collided keys in a linked list
Describe a situation where a hash table wouldn't be as useful as a binary search tree finding the max or min
What is one thing that is more clear to you on hash tables now I understand hash functions more

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 nice work, you hit the learning goals here. Well done. Do take a look at my notes regarding time complexity and let me know if you have questions.

Comment on lines +3 to 5
// Time Complexity: O(n * m)
// Space Complexity: O(n)
function grouped_anagrams(strings) {

Choose a reason for hiding this comment

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

The Time complexity would be O(n) if the words aren't too long. Or O(m * n log n) if the words are (m words and each word is at most n letters). The sort is a mergesort and it costs the most with each word.

Comment on lines +37 to +39
if(listObj[a] == listObj[b]){
return -1
}else{

Choose a reason for hiding this comment

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

Why not just subtract?

Comment on lines +21 to 23
// Time Complexity: O(n)
// Space Complexity: O(n)
function 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.

Since you're doing a sort it's O(n log n) time complexity.

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