style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@ -3,8 +3,10 @@ package com.thealgorithms.misc;
import java.util.*;
/*
*A matrix is sparse if many of its coefficients are zero (In general if 2/3rd of matrix elements are 0, it is considered as sparse).
*The interest in sparsity arises because its exploitation can lead to enormous computational savings and because many large matrix problems that occur in practice are sparse.
*A matrix is sparse if many of its coefficients are zero (In general if 2/3rd of matrix elements
*are 0, it is considered as sparse). The interest in sparsity arises because its exploitation can
*lead to enormous computational savings and because many large matrix problems that occur in
*practice are sparse.
*
* @author Ojasva Jain
*/
@ -19,7 +21,7 @@ class Sparcity {
*/
static double sparcity(double[][] mat) {
int zero = 0;
//Traversing the matrix to count number of zeroes
// Traversing the matrix to count number of zeroes
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
if (mat[i][j] == 0) {
@ -27,11 +29,11 @@ class Sparcity {
}
}
}
//return sparcity
// return sparcity
return ((double) zero / (mat.length * mat[1].length));
}
//Driver method
// Driver method
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter number of rows in matrix: ");