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

Maple: Rhyannon Rodriguez #69

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

Conversation

rhyannonjoy
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important?
Hashing gives a more secure and adjustable method of retrieving data compared to any other data structure

How can you judge if a hash function is good or not? |

  1. The hash value is fully determined by the data being hashed
  2. The hash function uses all the input data
  3. The hash function "uniformly" distributes the data across the entire set of possible hash values 4) The hash function generates very different hash values for similar strings

Is there a perfect hash function? If so what is it? |
A perfect hash function is one that maps the set of actual key values to the table without any collisions

Describe a strategy to handle collisions in a hash table |
Have each bucket contain a linked list of elements that are hashed to that bucket or dynamic resizing, which may include, but is not restricted to: resizing by copying all entries, incremental resizing & monotonic keys.

Describe a situation where a hash table wouldn't be as useful as a binary search tree |
Binary Search Trees are generally memory-efficient since they do not reserve more memory than they need to, so if you have any memory considerations at all, BST would be more useful.

What is one thing that is more clear to you on hash tables now |
Main advantage of hash tables is the constant O(1) speed of access

@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 left some notes on your time complexity calculations for the anagrams and sudoku problems, but overall this demonstrates sufficient mastery of the material and therefore is good enough for a Green!

Time Complexity: ?
Space Complexity: ?
Time Complexity: While there appears only a single for-loop,
.join() adds O(N) & sorted() adds O(nlogn) during their ideal case

Choose a reason for hiding this comment

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

Note though, that the n you refer to is the number of letters in each word, not the number of words in the list (let's call that m). Since the O(n * log(n)) sorted call gets called m times, it would be more accurate to say that it is O(m * n * log(n)).

However, we can make a simplifying assumption. Given that we know the input is a list of English words, and that words in English don't get too large (about 5 letters per word on average), the effect of n is going to be dwarfed by the effect of m, the number of words in the list. After all, there may be hundreds or thousands of words in the list, but there are not going to be words of that size most likely.

Space Complexity: ?
"""
pass
Time Complexity: Quadratic O(N^2) - nested for loop

Choose a reason for hiding this comment

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

This would be true if we took in arbitrary nxn grids, but luckily since we only accept 3x3 grids, we can actually just say this is O(n)!

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