Skip to content

Conversation

@DLozanoC
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? Hash functions allow us to reduce lookup times to O(1)
How can you judge if a hash function is good or not? When it has few to no collisions and has constant time
Is there a perfect hash function? If so what is it? A hash function with no collisions, because the fewer the collisions the more efficient the function is
Describe a strategy to handle collisions in a hash table Linear Probing: When trying to add an element in x index and that index is occupied, the hash table checks the next spot available until it finds one
Describe a situation where a hash table wouldn't be as useful as a binary search tree When it is not possible to have unique keys
What is one thing that is more clear to you on hash tables now How to deal with collisions (and what collisions are)

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.

✨ Really nice work, Diana. Let me know what questions you have.

🟢

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

Choose a reason for hiding this comment

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

✨ Nice!

frequency[num] = 1
else:
frequency[num] += 1
sorted_hash = sorted(frequency.items(), key=lambda x:(x[1]), reverse=True)

Choose a reason for hiding this comment

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

🌟 Nice lambda function

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