Conversation
|
Grabbing this to grade! |
chimerror
left a comment
There was a problem hiding this comment.
Good work! I left some comments about your complexity calculations, as well as a hint on the subgrid part of the sudoku problem, but otherwise this looks good enough for a Green!
| Each subarray will have strings which are anagrams of each other | ||
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: O(n^2) |
There was a problem hiding this comment.
My guess is that you're trying to account for the sort in line 10, but this answer is wrong in that case. sorted takes up O(m * log(m)) time where m is the number of characters in the word. Since I'm assuming n stands for the number of words in the list, that would make it O(n * m * log(m)). When doing these, you can only really have each variable stand for one thing.
However, under the assumption that our input is made up of English words, we can "ignore" the call to sorted. English words tend to be short, about 4.7 letters per word on average, so the effect of the length of the words would be quickly dwarfed by the number of words in the list. There may be hundreds or thousands of words in the list reasonably, but probably not that many letters in the words.
With that simplification we can just say the time complexity is O(n), where n is the number of words in the list.
Your space complexity calculation and implementation are fine, though.
| In the case of a tie it will select the first occuring element. | ||
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: O(n) + O(n log n)?? |
There was a problem hiding this comment.
This is almost right. Usually when doing big-o notation, everything goes in one "O" so your answer would be better expressed as O(n + n * log(n)). However, in that case, as the n * log(n) part will increase in size quicker than the n part (like when n^2 or n * n dwarfs n), we can just only keep that part to reduce down to O(n * log(n)).
Your space complexity and implementation are fine, though.
| column_dictionary[table[j][i]] = "yay!" | ||
|
|
||
| # check sub-grid | ||
| # ???? |
There was a problem hiding this comment.
As this question is optional, not finishing this is fine, but to give a bit of a hint...
I don't think you are going to really be able to do this in the same loop as the rows and columns. You are going to need another nested loop over the 3x3 sub grid, which is itself nested in a loop over each sub grid. In the instructor solution, the indices of the the subgrids are actually written out as a constant array of pairs, but there's other ways.
But once again, no need to answer this, just giving a hint in case you want to come back and answer this.
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: O(n^2) | ||
| Space Complexity: O(n) |
There was a problem hiding this comment.
These calculations are correct given your current algorithm, but a full solution will probably push the time complexity up.
At the same time, since we assume all grids are 3x3 the number of steps and space used will always be constant so you could consider this to be O(1) in space and time complexity. Of course, allowing for any size of boards will change that, but in this case, it's always 3x3.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions