Skip to content

Conversation

amyesh
Copy link

@amyesh amyesh commented Sep 16, 2019

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? To facilitate an O(1) lookup time with minimal collisions.
How can you judge if a hash function is good or not? When it avoids collisions and distributes data well.
Is there a perfect hash function? If so what is it? Nope.
Describe a strategy to handle collisions in a hash table Quadratic probing, where if the bucket is full, the developer uses an algorithm that looks for an empty bucket at exponentially larger distances from the collision points each time a collision occurs.
Describe a situation where a hash table wouldn't be as useful as a binary search tree When the data needs to be sorted before searched.
What is one thing that is more clear to you on hash tables now How they're created under the hood, strategies for storing that data efficiently, and the logic around why it's stored that way.

@amyesh amyesh changed the title Ports - Amy M. Amy M. Sep 16, 2019
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.

Really nicely done. You got all the methods and hit all the learning goals here. Well done. One question: What is the Big-O of your Sudoku method?

# Each subarray will have strings which are anagrams of each other
# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(n)

Choose a reason for hiding this comment

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

Where the words are small, yes.

# Space Complexity: ?
# Time Complexity: O(n)
# Space Complexity: O(n)
def top_k_frequent_elements(list, k)

Choose a reason for hiding this comment

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

👍

# The same digit cannot appear twice or more in the same
# The same digit cannot appear twice or more in the same
# row, column or 3x3 subgrid
# Time Complexity: ?

Choose a reason for hiding this comment

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

No answers here?

# creates subsections
def create_sub_sections(table)
# code snippet from https://stackoverflow.com/questions/41020695/how-do-i-split-a-9x9-array-into-9-3x3-components
table.each_slice(3).map { |row| row.transpose.each_slice(3).map { |section| section.transpose } }.flatten(1)

Choose a reason for hiding this comment

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

Very slick! I'm glad you cited where you got this.

# Space Complexity: ?

# returns a hash of a valid sudoku row
def get_valid_sudoku

Choose a reason for hiding this comment

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

👍 I did the same thing

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