I’m looking for “how do you find it” because I have no idea how to approach the search for the complexity of the algorithm of my program.
I wrote sudoku solver using java, without regard to efficiency (I wanted to try to get it to work recursively, with which I succeeded!)
Some background:
My strategy uses rollback to determine for a given Sudoku puzzle whether the puzzle has only one unique solution or not. Therefore, I mainly read in a given puzzle and solve it. As soon as I find one solution, I do not have to do it; I need to continue to study further solutions. In the end, one of three possible results occurs: the puzzle is not solvable at all, the puzzle has a unique solution, or the puzzle has several solutions.
My program reads in the coordinates of the puzzle from a file that has one row for each digit, consisting of a row, column and number. By my own agreement, the top left square of 7 is written as 007.
Implementation:
I load the values from the file and save them in a two-dimensional array. I go down the array until I find an empty (unfilled value) and set it to 1. And check for any conflicts (whether the entered value is valid or not). If so, I move on to the next value. If not, I increment the value by 1 until I find a digit that works, or if none of them work (1 through 9), I go back 1 step to the last value that I set, and I increment it ( using recursion). I decided when all 81 elements are filled, without conflicts. If any solutions are found, I print them to the terminal. Otherwise, if I try to "go back" to the first FIRST element that I initially changed, it means that there were no solutions.
? , linear [O (n)], , : (