Found 75 Articles for Campus Interview

Java Program to Interchange Elements of First and Last in a Matrix Across Rows

AmitDiwan
Updated on 29-Mar-2022 09:17:39

115 Views

In this article, we will understand how to interchange elements of first and last in a matrix across rows. The matrix has a row and column arrangement of its elements. A matrix with m rows and n columns can be called as m × n matrix.Individual entries in the matrix are called element and can be represented by a[i][j] which suggests that the element a is present in the ith row and jth column.Below is a demonstration of the same −Suppose our input is −The matrix is defined as: 4 5 6 7 1 7 3 4 11 12 13 ... Read More

Java Program to Compute the Sum of Diagonals of a Matrix

AmitDiwan
Updated on 29-Mar-2022 09:12:17

8K+ Views

In this article, we will understand how to compute the sum of diagonals of a matrix. The matrix has a row and column arrangement of its elements. The principal diagonal is a diagonal in a square matrix that goes from the upper left corner to the lower right corner.The secondary diagonal is a diagonal of a square matrix that goes from the lower left corner to the upper right corner.Below is a demonstration of the same −Suppose our input is −The input matrix: 4 5 6 7 1 7 3 4 11 12 13 14 23 24 25 50The desired ... Read More

Java Program to Rotate Matrix Elements

AmitDiwan
Updated on 29-Mar-2022 09:04:31

464 Views

In this article, we will understand how to rotate matrix elements. A matrix is representation of the elements in rows and columns. Matrix rotation is shifting the position of each element of the matrix by 1 position towards it’s right or left.Below is a demonstration of the same −Suppose our input is −The matrix is defined as 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16The desired output would be −The matrix after one rotation: 5 1 2 3 9 10 6 4 13 11 7 8 14 15 16 12AlgorithmStep 1 - ... Read More

Java Program to Print Boundary Elements of a Matrix

AmitDiwan
Updated on 30-Mar-2022 08:01:35

2K+ Views

In this article, we will understand how to print boundary elements of a matrix. A matrix is representation of the elements in rows and columns. Boundary elements are those elements which are not surrounded by elements on all four directions. For example, the elements in the first row, first column, last row and last column.Below is a demonstration of the same −Suppose our input is −The input matrix: 9 8 9 8 8 7 8 7 7 6 7 6 6 5 6 5The desired output would be −The border elements of the matrix is: 9 8 9 8 8 ... Read More

Java Program to Calculate Standard Deviation

AmitDiwan
Updated on 29-Mar-2022 08:38:03

2K+ Views

In this article, we will understand how to calculate standard deviation. The standard deviation is the measure of how spread-out numbers are. Its symbol is sigma( σ ). It is the square root of variance.Standard deviation is computed using the formula square root of ∑(Xi - ų)2 / N where Xi is the element of the array, ų is mean of the elements of the array, N is the number of elements, ∑ is the sum of the each element.Below is a demonstration of the same −Suppose our input is −Input Array : [ 35.0, 48.0, 60.0, 71.0, 80.0, 95.0, 130.0 ... Read More

Previous 1 ... 4 5 6 7 8
Advertisements