1

I am implementing a backtracking algorithm to solve Sudoku puzzles and am required to do empirical analysis of the algorithm. However, i am finding difficulty in understanding the time complexity of this backtracking algorithm to solve a Sudoku puzzle. The sudoku board is a 9 by 9 grid, so each blank space can take values from 1-9 but it first checks the row,column,3x3 box to see if it is safe to do so and there are m blank spaces. I loop through the grid row by row looking for a blank space and then loop through numbers 1-9, checking which number is safe to place. If the number is safe, i place it there then recall my function again (recurrence) to check the next blank space and so on. If it does not lead to a solution, the algorithm backtracks and then places the next number in that space and tries again.

I will need to generate grids that will be the best/worst case time complexity of the backtracking algorithm. So to be able to do that i need to understand the time complexity of the backtracking algorithm implemented. If anyone can help explain to me the time complexity of it and how best/worst case is calculated for sudoku backtracking or if anyone can link me with appropriate documents that can be of help, I'd really appreciate it.

Thanks in advance :)

Apollo77
  • 11
  • 2
  • The worst-case is exponential in the size of the sudoku. If it would not, P equals NP (which is unknown). Finding those worst-cases though is probably not trivial. – sascha Oct 20 '18 at 22:54
  • Possible duplicate of [Algorithm Complexity (Big-O) of sudoku solver](https://stackoverflow.com/questions/15327376/algorithm-complexity-big-o-of-sudoku-solver) – Christabella Irwanto Nov 12 '18 at 06:56

0 Answers0