I need to design an algorithm that tells if a given matrix of integers is a valid latin square or not. I've never worked with Latin Sqares before so I don't know where to begin. After some research I only found algorithms for writing a Latin square. The only thing that occured to me is that the sum of all columns and rows should be the same but then I have to check for every number if it's repeated in that same row and column. Doing it that way the program will have a big time cost. I'm using C++.
How to tell if a tri dimensional square is a Latin Square
721 Views Asked by Buradi At
1
There are 1 best solutions below
Related Questions in C++
- C++ using std::vector across boundaries
- Linked list without struct
- Connecting Signal QML to C++ (Qt5)
- how to get the reference of struct soap inherited in C++ Proxy/Service class
- Why we can't assign value to pointer
- Conversion of objects in c++
- shared_ptr: "is not a type" error
- C++ template using pointer and non pointer arguments in a QVector
- C++ SFML 2.2 vectors
- Lifetime of temporary objects
- I want to be able to use 4 different variables in a select statement in c ++
- segmentation fault: 11, extracting data in vector
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- How can I print all the values in this linked list inside a hash table?
- Configured TTL for A record(s) backing CNAME records
Related Questions in MULTIDIMENSIONAL-ARRAY
- How to sort a multi-dimensional array by the second array in descending order?
- C programming: Create and write 2D array of files as function
- Working with multiple array in PHP
- PHP multidimensional array, average of duplicate values
- Multiple parameters in a Dictionary
- navigate through multidimensional PHP array by relative path
- How to double values in 2d array? C++
- Multidimensional Array view defined line
- .NET Array with Multiple Data Types
- Multidimensional Array modify values
- Rearrange multidimensional array from other array
- Callback set_message not working with multidimensional array post
- Javascript push multidimensional array only checked checkboxes
- Program crash while trying to print a bidimensional array
- How to extract all 2nd level values (leaf nodes) from a 2-dimensional array and join with commas?
Related Questions in LATIN-SQUARE
- Java: Contiguous region in a multi-dimensional array, used to implement a Latin Square
- Latin squares generator? (Sudoku-like constraint problem)
- Filling a 2D array with randomised numbers
- Using MATLAB to create a latin square matrix
- How to generate a list of all distinct 3x3 Latin Square in Python
- A way of reduction skyscrapper (latin square with height clues) to SAT
- Need help shifting latin square in Java
- create a matrix and permutate each line
- How to tell if a tri dimensional square is a Latin Square
- Generating Random Latin Square Continuous Loop
- Animate Javascript Canvas while in recursive calculation
- Creating a Latin Square program in Python
- Why this program find only one solution?
- Creating an efficient local search technique in Python for Latin Squares
- Understanding this C function
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
No, since you can reject a lot of matrix before you reach the end. So algorithm will fail fast. Worst estimation of working algorithm is
O(n*(n+1))(I assuming that you evaluate only square matrix where dimension is n*n). But average algorithm will be much better - because it will fail as first in-equality found.Update: The average complexity can be rough and approximately estimated as number of real Latin Squares to number of possible squares. To do this we need introduce understand
normalizedsquare. Two squares bellow are intuitively the same :So to normalize this we can use substitution for numbers 1...n of n*n square. So first form wins.
For normalized squares Wiki provides an estimation
Are you scared? But for average we also need to divide this formula by total number of matrix. To do this see this formula http://en.wikipedia.org/wiki/Combination