JavaScript Program to check if matrix is lower triangular Last Updated : 12 Sep, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Given a square matrix and the task is to check the matrix is in lower triangular form or not. A square matrix is called lower triangular if all the entries above the main diagonal are zero. Examples: Input : mat[4][4] = {{1, 0, 0, 0}, {1, 4, 0, 0}, {4, 6, 2, 0}, {0, 4, 7, 6}};Output : Matrix is in lower triangular form.Input : mat[4][4] = {{1, 0, 0, 0}, {4, 3, 0, 1}, {7, 9, 2, 0}, {8, 5, 3, 6}};Output : Matrix is not in lower triangular form. JavaScript // JavaScript Program to check for // a lower triangular matrix. let N = 4; // Function to check matrix is // in lower triangular form or not. function isLowerTriangularMatrix(mat) { for (let i = 0; i < N; i++) for (let j = i + 1; j < N; j++) if (mat[i][j] != 0) return false; return true; } // Driver function. let mat = [[1, 0, 0, 0], [1, 4, 0, 0], [4, 6, 2, 0], [0, 4, 7, 6]]; // Function call if (isLowerTriangularMatrix(mat)) console.log("Yes"); else console.log("No"); // contributed by sravan kumar OutputYes Complexity Analysis:Time Complexity: O(n2), where n represents the number of rows and columns of the given matrix.Auxiliary Space: O(1), no extra space is required, so it is a constant.Please refer complete article on Program to check if matrix is lower triangular for more details! Comment More infoAdvertise with us Next Article JavaScript Program to check if matrix is lower triangular K kartik Follow Improve Article Tags : JavaScript JavaScript-Program Similar Reads Javascript Program to check if matrix is upper triangular Given a square matrix and the task is to check the matrix is in upper triangular form or not. A square matrix is called upper triangular if all the entries below the main diagonal are zero.Examples: Input : mat[4][4] = {{1, 3, 5, 3}, {0, 4, 6, 2}, {0, 0, 2, 5}, {0, 0, 0, 6}};Output : Matrix is in Up 2 min read Javascript Program for Markov matrix 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.Example of Markov MatrixExamples: Input :1 0 00.5 0 0.50 0 1Output : yesExplanation :Sum of each row results to 1, therefore it is a Markov Matrix.Input :1 0 00 0 21 0 0Outpu 2 min read Javascript Program to check if a matrix is symmetric A square matrix is said to be symmetric matrix if the transpose of the matrix is same as the given matrix. Symmetric matrix can be obtain by changing row to column and column to row.Examples: Input : 1 2 3 2 1 4 3 4 3 Output : Yes Input : 3 5 8 3 4 7 8 5 3 Output : NoA Simple solution is to do follo 2 min read Javascript Program to check Involutory Matrix Given a matrix, the task is to check matrix is an involutory matrix or not. Involutory Matrix: A matrix is said to be an involutory matrix if the matrix multiplied by itself returns the identity matrix. The involutory matrix is the matrix that is its inverse. The matrix A is said to be an involutory 2 min read Javascript Program to Check if a given matrix is sparse or not A matrix is a two-dimensional data object having m rows and n columns, therefore a total of m*n values. If most of the values of a matrix are 0 then we say that the matrix is sparse. Consider a definition of Sparse where a matrix is considered sparse if the number of 0s is more than half of the elem 2 min read Like