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

C16 - Afina Walton #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

afinawalton
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? It can reduce the number of collisions; you can reliably get the same value from the same key.
How can you judge if a hash function is good or not? If it reduces the number of collisions and there is a random element to the hashing, making it difficult to unscramble.
Is there a perfect hash function? If so what is it? Nope. Collisions happen inevitably.
Describe a strategy to handle collisions in a hash table Chaining, in which each bucket contains the head of a linked list, so that multiple elements exist in different places in memory.
Describe a situation where a hash table wouldn't be as useful as a binary search tree If we wanted to iterate through the hash table, it would take more time than a BST.
What is one thing that is more clear to you on hash tables now That they are built on top of arrays.

Copy link

@kyra-patton kyra-patton 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 Afina. I left some comments on time and space complexity, but otherwise looks good. Answers to the comprehension questions are also solid.

🟢

@@ -1,19 +1,54 @@
// This method will return an array of arrays.
// Each subarray will have strings which are anagrams of each other
// Time Complexity: ?
// Space Complexity: ?
// Time Complexity: O(N^2)

Choose a reason for hiding this comment

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

✨If you want to include sorting the strings in your time complexity, we could say that the time complexity is O(n m log(m)) where m is the length of the string you are sorting and n is the length of strings

Space complexity would also be O(n) where counter and grouped are each of size n

return counterArray
}

function topKFrequentElements(list, k) {

Choose a reason for hiding this comment

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

✨ Nice! Since you are sorting the array, it would be 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