Skip to content

Conversation

@kanderson38
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? It reduces collisions and therefore brings the time complexity of accessing values closer to O(n).
How can you judge if a hash function is good or not? If it's fast, produces only a few collisions, and produces an almost-random distribution of key/value pairs, it's a good hash function.
Is there a perfect hash function? If so what is it? Nope!
Describe a strategy to handle collisions in a hash table You can use linear probing, which involves checking each successive bucket in the array (starting from the collision point) and finding the next empty bucket.
Describe a situation where a hash table wouldn't be as useful as a binary search tree A BST would be more useful if the order of the values were important (you can run an in-order traversal on a BST, but a hash's values are unordered).
What is one thing that is more clear to you on hash tables now The probing strategies used to avoid collisions.

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.

Nice work, this is pretty well done. Do take a look at my statements on the Big-O of these. Otherwise this is quite well done.

// Each subarray will have strings which are anagrams of each other
// Time Complexity: ?
// Space Complexity: ?
// Time Complexity: O(n log n), where n is the combined length of the input strings (since the strings are being sorted)

Choose a reason for hiding this comment

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

But you're not sorting an array of all the characters in all the strings.

Instead I would say that the time complexity is O(n * m log m), where n is the number of strings and m is the length of the largest string. If you could assume the all the strings were less than a certain number of characters you could then say it's O(n).

// row, column or 3x3 subgrid
// Time Complexity: ?
// Space Complexity: ?
// Time Complexity: O(n), where n is the number of elements in the sudoku table

Choose a reason for hiding this comment

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

I would say instead O(n2) where n is the length of a side of the sudoku table.

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