Update Sudoku_Solver.java
parent
07239d92b3
commit
fe436f26a0
|
@ -4,14 +4,16 @@
|
||||||
//THIS IS THE ALGORITHM USING BACKTRACKING FOR SOLVING SUDOKU.
|
//THIS IS THE ALGORITHM USING BACKTRACKING FOR SOLVING SUDOKU.
|
||||||
|
|
||||||
// SUDOKU IS A VERY POPULAR PUZZLE GAME IN WHICH WE HAVE A 9X9 GRID IN WHICH WE HAVE TO FILL DIGITS (1-9) IN SUCH A MANNER THAT NO DIGIT IS REPEATED IN THE SAME ROW,
|
// SUDOKU IS A VERY POPULAR PUZZLE GAME IN WHICH WE HAVE A 9X9 GRID IN WHICH WE HAVE TO FILL DIGITS (1-9) IN SUCH A MANNER THAT NO DIGIT IS REPEATED IN THE SAME ROW,
|
||||||
// OR IN THE SAME COLUMN OR THE INSIDE THE SMALL GRID ( THE SMALL GRID IS A 3x3 GRID, WHICH IS A PART OF THIS 9X9 GRID, THERE ARE SUCH 9 GRIDS IN THE BIGGER GRID).
|
// OR IN THE SAME COLUMN OR INSIDE THE SMALL GRID ( THE SMALL GRID IS A 3x3 GRID, WHICH IS A PART OF THIS 9X9 GRID, THERE ARE SUCH 9 GRIDS IN THE BIGGER GRID).
|
||||||
// SO OUR TASK IS TO FILL THE NUMBERS IN THE BLANK SPACES (SOME SPACES WILL ALREADY BE FILLED WHICH CAN'T BE CHANGED), SUCH THAT IT MATCHES ALL THE CONDITIONS. WE USE
|
// SO OUR TASK IS TO FILL THE NUMBERS IN THE BLANK SPACES (SOME SPACES WILL ALREADY BE FILLED WHICH CAN'T BE CHANGED), SUCH THAT IT MATCHES ALL THE CONDITIONS. WE USE
|
||||||
// BACKTRACKING ALGORITHM HERE, WHICH SOLVES THIS PROBLEM IN VARIOUS HIT AND TRIALS AND FINALLY GIVES THE OUTPUT AS THE RESULTANT SOLUTION.
|
// BACKTRACKING ALGORITHM HERE, WHICH SOLVES THIS PROBLEM IN VARIOUS HIT AND TRIALS AND FINALLY GIVES THE OUTPUT AS THE RESULTANT SOLUTION.
|
||||||
|
//(NOTE: BLANK CELLS ARE FILLED WITH ZEROS)
|
||||||
|
|
||||||
|
|
||||||
//*****************ALGORITHM INFORMATION******************\\
|
//*****************ALGORITHM INFORMATION******************\\
|
||||||
|
|
||||||
// Time complexity: O (9^ (n*n)). For every unassigned index, there are 9 possible options so the time complexity is O (9^ (n*n))
|
// Time complexity: O (9^(N x N)). For every unassigned index, there are 9 possible options so the time complexity is O (9^ (n*n))
|
||||||
|
// Space complexity: O(N x N) as it only operates on (N x N) grid
|
||||||
|
|
||||||
//*********************************************************\\
|
//*********************************************************\\
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue