From fe436f26a09968c47b799bdfa1847d39adf532c6 Mon Sep 17 00:00:00 2001 From: Shawaiz Siddiqui <105994493+Shawaiz22@users.noreply.github.com> Date: Wed, 12 Oct 2022 12:50:36 +0530 Subject: [PATCH] Update Sudoku_Solver.java --- algorithms/Java/backtracking/Sudoku_Solver.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/algorithms/Java/backtracking/Sudoku_Solver.java b/algorithms/Java/backtracking/Sudoku_Solver.java index 61743b08..0a67adb6 100644 --- a/algorithms/Java/backtracking/Sudoku_Solver.java +++ b/algorithms/Java/backtracking/Sudoku_Solver.java @@ -4,14 +4,16 @@ //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, -// 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 // 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******************\\ -// 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 //*********************************************************\\