[Matthew Zhang] - Backtracking Algorithm with number constraints #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview:
Implemented a Sudoku Solving algorithm using backtracking. Used arrays to represent rows, columns and sub-boxes of the grid to make checking for valid operations more efficient.
Time Complexity Explanation:
The time complexity of this algorithm is difficult to determine exactly as it depends on the input puzzle. Technically we can say it is constant, but the constant is very large so it may be worth analyzing the exact number of operations. In the worst case, the algorithm starts with an empty grid and tries every possible combination, which would result in O(9^(n^2)) for an n*n grid (n=9 for standard Sudoku). However, the average case is much better due to early stopping when an invalid state is reached.