Given a m x n 2D matrix, check if it is a Markov Matrix.
Markov Matrix : The matrix in which the sum of each row is equal to 1.
Input : 1 0 0 0.5 0 0.5 0 0 1 Output : yes Explanation : Sum of each row results to 1, therefore it is a Markov Matrix. Input : 1 0 0 0 0 2 1 0 0 Output : no
Approach : Initialize a 2D array, then take another single dimensional array to store the sum of each rows of the matrix, and check whether all the sum stored in this 1D array is equal to 1, if yes then it is Markov matrix else not.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Program to check diagonal matrix and scalar matrix
- Finding the probability of a state at a given time in a Markov chain | Set 2
- Program to convert given Matrix to a Diagonal Matrix
- Program to check if a matrix is Binary matrix or not
- C++ program to Convert a Matrix to Sparse Matrix
- Program for Rank of Matrix
- Program for Identity Matrix
- Program to find the Sum of each Row and each Column of a Matrix
- Program to check idempotent matrix
- Program to check Involutory Matrix
- Program to check if a matrix is symmetric
- Program to Print Matrix in Z form
- Program to check if matrix is singular or not
- Program for scalar multiplication of a matrix
- Program to find all types of Matrix
- Program to find transpose of a matrix
- Program to print the Diagonals of a Matrix
- Program to Interchange Diagonals of Matrix
- Program to check if matrix is upper triangular
- Program to print the Diagonals of a Matrix in O(N) time
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.