On some randomized algorithms and their evaluation

Krasimir Yordzhev
2024-08-08
Abstract:The paper considers implementations of some randomized algorithms in connection with obtaining a random $n^2 \times n^2$ Sudoku matrix with programming language C++. For this purpose we describes the set $\Pi_n$ of all $(2n) \times n$ matrices, consisting of elements of the set $\mathbb{Z}_n =\{ 1,2,\ldots ,n\}$, such that every row is a permutation. We emphasize the relationship between these matrices and the $n^2 \times n^2$ Sudoku matrices. An algorithm to obtain random $\Pi_n$ matrices is presented in this paper. Several auxiliary algorithms that are related to the underlying problem have been described. We evaluated all algorithms according to two criteria - probability evaluation, and time for generation of random objects and checking of belonging to a specific set. This evaluations are interesting from both theoretical and practical point of view because they are particularly useful in the analysis of computer programs.
Discrete Mathematics,Data Structures and Algorithms,Combinatorics
What problem does this paper attempt to address?
The problem that this paper attempts to solve is to generate random \(n^2\times n^2\) Sudoku matrices and evaluate the performance of relevant randomization algorithms. Specifically, the author solves this problem through the following points: 1. **Definition and construction of specific matrix sets**: - Define the set \(\Pi_n\), that is, all \((2n)\times n\) matrices, where each row of these matrices is a permutation of the set \(Z_n = \{1, 2,\ldots, n\}\). - Define \(S\)-permutation matrices, that is, \(n^2\times n^2\) matrices composed of multiple \(n\times n\) sub - matrices, with only one element in each sub - matrix being 1 and the rest being 0. 2. **Methods for generating random matrices**: - Propose an algorithm (Algorithm 5) for generating random \(\Pi_n\) matrices and prove that its probability evaluation is 1, that is, a valid \(\Pi_n\) matrix can be obtained every time it runs. - Propose a method for generating random \(S\)-permutation matrices and analyze their probability and time complexity. 3. **Evaluating algorithm performance**: - Use two criteria to evaluate the algorithm: probability evaluation and the time required for generation and checking. - For generating random Sudoku matrices, analyze the time complexity and success rate of different methods. 4. **Establishing the relationship between \(\Pi_n\) matrices and Sudoku matrices**: - Prove that an \(S\)-permutation matrix can be uniquely constructed from a \(\Pi_n\) matrix, and there is a bijective relationship between these two sets. - Using this relationship, propose a more efficient algorithm (Algorithm 8) for generating random Sudoku matrices. ### Formula summary - The size of the set \(\Pi_n\): \[ |\Pi_n|=(n!)^{2n} \] - The size of the set \(\Sigma_{n^2}\): \[ |\Sigma_{n^2}|=(n!)^{2n} \] - Probability evaluation for generating random \(\Pi_n\) matrices: \[ p_3(n)=\frac{(n!)^{2n}}{n^{2n^2}} \] - Probability evaluation for generating random \(S\)-permutation matrices: \[ p_5(n)=\frac{(n!)^{2n}}{2^{n^4}} \] - Probability evaluation for generating random Sudoku matrices: \[ p_6(n)=\frac{\sigma_n}{n^{2n^2}} \] ### Conclusion This paper proposes a new method for generating random Sudoku matrices by introducing the concepts of \(\Pi_n\) matrices and \(S\)-permutation matrices and conducts a detailed performance evaluation. This not only helps to understand the problem of generating Sudoku matrices but also provides valuable references for other similar problems.