Skip to content

Conversation

Mary-Tian
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important?
Hashing is quicker than searching for lists and arrays.

How can you judge if a hash function is good or not? |
Is it efficient
Is each table position equally likely for each key

Is there a perfect hash function? If so what is it? |
A perfect hash function maps each of the keys to a unique integer, with no collisions.

Describe a strategy to handle collisions in a hash table |
Separate chaining - each element in hash table is a linked list. To store an element in the hash table you must insert it into a specific linked list.

Describe a situation where a hash table wouldn't be as useful as a binary search tree |
Hash table has to have unique keys. If a dataset cannot provide unique key values, a binary search tree is better.

What is one thing that is more clear to you on hash tables now |
Hash tables can be much faster than other data structures.

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, Mary. The comprehension questions are not filled out so I am marking this as a yellow. Let me know what questions you have.

🟡

Each subarray will have strings which are anagrams of each other
Time Complexity: ?
Space Complexity: ?
Time Complexity: O(nlogn)? Not sure on this

Choose a reason for hiding this comment

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

⏱ Time complexity will be O(n) or O(n*m), where n is the length of strings and m is the length of the longest element in strings since sorted is an O(m) operation. However, if we assume that all words in strings are valid English words, we can reduce the time complexity down to O(n) as m will be relatively small

Time Complexity: ?
Space Complexity: ?
Time Complexity: 0(n)
Space Complexity: 0(n)

Choose a reason for hiding this comment

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

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