2

i want to know the running time of Pencil and paper algorithm for Sudoku Solver following are the statements of algorithm http://www.ams.org/notices/200904/tx090400460p.pdf:

1. Find all forced numbers in the puzzle.
2. Mark up the puzzle.
3. Search iteratively for pre-emptive sets in all rows, columns, and boxes—taking appropriate cross out action as each new pre-emptive set is discovered until
either

4. (a) a solution is found or
   (b) a  random choice must be made for continuation.

If 4(a), then end; if 4(b), then go to step 3

i want to find running time of above algorithm in terms of Big-O notation.

Afzaal Ahmad
  • 187
  • 1
  • 12
  • 4
    Big-O describes asymptotic run-times in terms of the length/number of the inputs. Since you have a fixed number of inputs, you also have a fixed maximum run-time. So it's O(1). – RBarryYoung May 21 '15 at 14:23
  • 1
    .. and note that the size and range of Soduku is intrinsic to it's nature and the solution algorithm, it cannot be naturally extended to ill-defined "larger inputs". – RBarryYoung May 21 '15 at 14:24
  • 3
    @vib Actually, as the paper you reference mentions, Sudoku must be considered to be a problem *of size (n^2 x n^2) with integers between 1 and n^2* (where n=3 for the traditional case). The definition "*of size n x n, with integers between 1 and n*" is ill-defined for most n (like say, 11). And at an off-hand guess, I'd say that it's Big-O was bound by O(n!^2) to O((n^2)!). Also, the referenced paper seems to show how to turn a series of Latin Squares solutions into a completed Sudoku grid. Note that this is *not* the same as solving a Sudoku *Puzzle*, which would have to go the other way. – RBarryYoung May 21 '15 at 15:29
  • @RBarryYoung thanks for your answer it helped me in understanding, i only want to ask u one more question why u have written `Big-O was bound by O(n!^2) to O((n^2)!)` i didn't understand why u used `n!` and not simple `n` need a little explanation on this `n!` – Afzaal Ahmad May 21 '15 at 17:26
  • 1
    @AfzaalAhmad The number of ordered permutations of n different things is n!. Sudoku puzzles are basically permutation problems (with n=9). If you assume worst case, that you cannot use any rules to improve on that, then you are stuck with something in the range of (n!*n!) to (n*n)! because it is a two-dimensional (9x9) puzzle. – RBarryYoung May 22 '15 at 14:00

0 Answers0