- Programs List
- Program to calculate the area of rectangle
- Program to calculate the volume of sphere
- Program to find the area of the pentagon
- Program to find the area of parallelogram
- Program to find the area of square
- Program to find the surface area of sphere
- Program to find the volume of cone
- Program to find the volume of the cube
- Program to find the volume of cylinder
- Program to calculate the CGPA percentage
- Program to convert Celsius into Fahrenheit
- Program to convert days into years
- Program to convert Fahrenheit into Celsius
- Program to find the area of an equilateral triangle
- Program to find the area of a triangle
- Program to find the area of the right angle triangle
- Program to find the perimeter of the rectangle
- Program to find the simple interest
- Program to find the surface area of a cube
- Program to find the surface area of cuboid
- Program to find the surface area of the cylinder
- Program to Check Disarium number
- Program to Check Happy number
- Program to Check Harshad number
- Program to print all Disarium numbers between 1 to 100
- Program to print all Happy numbers between 1 to 100
- Program to print all Pronic numbers between 1 to 100
- Program to determine whether a given number is a Deficient number
- Program to determine whether a given number is an abundant number
- Program to determine whether a given number is a twisted prime number
- Program to print all abundant numbers between 1 to 100
- Program to print all Kaprekar numbers between 1 to 100
- Program to print all prime numbers between 1 to 100
- Program to print the average of n numbers
- Program to print the combination (nCr) of the given number
- Program to print the first 10 prime numbers
- Program to print the permutation (nPr) of the given number
- Program to print the sum of digits without using modulus
- Program to swap two numbers
- Program to swap two numbers without using the third variable
- Program to copy all the elements of one array into another array
- Program to find the frequency of each element of an array
- Program to left rotate the elements of an array
- Program to print the duplicate elements of an array
- Program to print the elements of an array
- Program to print the elements of an array in reverse order
- Program to print the elements of an array present on even position
- Program to print the elements of an array present on odd position
- Program to print the largest element present in an array
- Program to print the number of elements present in an array
- Program to print the smallest element present in an array
- Program to print the sum of all the elements of an array
- Program to right rotate the elements of an array
- Program to sort the elements of an array in ascending order
- Program to sort the elements of an array in descending order
- Program to calculate the addition of 2 matrices
- Program to calculate the subtraction of 2 matrices
- Program to determine whether a given matrix is an identity matrix
- Program to determine whether a given matrix is a sparse matrix
- Program to determine whether two matrices are equal
- Program to display the lower triangular matrix
- Program to display the upper triangular matrix
- Program to find the frequency of odd & even numbers in the given Matrix
- Program to find the product of two matrices
- Program to find the sum of each row and each column of a matrix
- Program to find the transpose of a given matrix
- Program to count the total number of punctuation characters exists in a string
- Program to count the total number of vowels and consonants in a string
- Program to determine whether two strings are the anagram
- Program to divide a string in 'N' equal parts
- Program to find all the permutations of a string
- Program to find all possible subsets of a string
- Program to find the longest repeating sequence in a string
- Program to remove all the white spaces from a string
- Program to replace lower-case characters with upper-case and vice versa
- Program to replace the spaces of a string with a specific character
- Program to Count the Total Number of Characters in a String
- Program to Count the Total Number of Words in a String
- Program to Determine Whether a Given String is Palindrome
- Program to Determine Whether One String is a Rotation of Another
- Program to Find Maximum and Minimum Occurring Character in a String
- Program to Find Reverse of a String
- Program to Find the Duplicate Characters in a String
- Program to Find the Duplicate Words in a String
- Program to Find the Frequency of Characters
- Program to Find the Largest and Smallest Word in a String
- Program to Find the Most Repeated Word in a Text File
- Program to Find the Number of Words in the Given Text File
- Program to Print Smallest and Biggest Possible Palindrome Word in a Given String
- Program to Separate the Individual Characters from a String
- Program to Swap two String Variables Without Using Third or Temp Variable
- Program To Print Following Pattern
- Program To Print Following Pattern
- Program To Print Following Pattern
- Program To Print Following Pattern
- Program To Print Following Pattern
- Program To Print Following Pattern
- Program To Print Following Pattern
- Program To Print Following Pattern
- Program To Print Following Pattern
- Program to Print Following Pattern
- Program to Print Following Pattern
- Program to Print Following Pattern
- Program to Print Following Pattern
- Program to Print Following Pattern
- Program to Print Following Pattern
- Program to Print Following Pattern
- Program to Print Following Pattern
- Program to Print Following Pattern
- Program to Print Following Pattern
- Program to Calculate the Difference Between the Sum of the Odd Level and Even Level Nodes of a Binary Tree
- Program to Construct a Binary Search Tree and Perform Deletion and Inorder Traversal
- Program to Convert Binary Tree to Binary Search Tree
- Program to Determine Whether all Leaves are at Same Level
- Program to Determine Whether two Trees are Identical
- Program to Find Maximum Width of a Binary Tree
- Program to Find the Largest Element in a Binary Tree
- Program to Find the Maximum Depth or Height of a Tree
- Program to Find the Nodes Which are at the Maximum Distance in a Binary Tree
- Program to Find the Smallest Element in a Binary Tree
- Program to Find the Sum of all the Nodes of a Binary Tree
- Program to Find the Total Number of Possible Binary Search Trees with N Keys
- Program to Implement Binary Tree using the Linked List
- Program to Search a Node in a Binary Tree
- Singly Linked List Examples
- Program to create and display a singly linked list
- Program to create a singly linked list of n nodes and count the number of nodes
- Program to create a singly linked list of n nodes and display it in reverse order
- Program to delete a new node from the beginning of the singly linked list
- Program to delete a new node from the middle of the singly linked list
- Program to delete a node from the end of the singly linked list
- Program to determine whether a singly linked list is the palindrome
- Program to find the maximum and minimum value node from a singly linked list
- Program to insert a new node at the middle of the singly linked list
- Program to insert a new node at the beginning of the singly linked list
- Program to insert a new node at the end of the singly linked list
- Program to remove duplicate elements from a singly linked list
- Program to search an element in a singly linked list
- Program to sort the elements of the singly linked list
- Program to swap nodes in a singly linked list without swapping data
- Program to swap the last element of the singly linked list from the first one
- Program to Create a Circular Linked List of N Nodes and Count the Number of Nodes
- Program to Create a Circular Linked List of N Nodes and Display it in Reverse Order
- Program to Create and Display a Circular Linked List
- Program to Delete a New Node From the Beginning of the Circular Linked List
- Program to Delete a New Node From the End of the Circular Linked List
- Program to Delete a New Node From the Middle of the Circular Linked List
- Program to Find the Maximum and Minimum Value Node From a Circular Linked List
- Program to Insert a New Node at the Beginning of the Circular Linked List
- Program to Insert a New Node at the End of the Circular Linked List
- Program to Insert a New Node at the Middle of the Circular Linked List
- Program to Remove Duplicate Elements From a Circular Linked List
- Program to Search an Element in a Circular Linked List
- Program to Sort the Elements of the Circular Linked List
- Program to Convert a Given Binary Tree to Doubly Linked List
- Program to Create a Doubly Linked List From a Ternary Tree
- Program to Create a Doubly Linked List of N Nodes and Count the Number of Nodes
- Program to Create a Doubly Linked List of N Nodes and Display it in Reverse Order
- Program to Create and Display a Doubly Linked List
- Program to Delete a New Node From the Beginning of the Doubly Linked List
- Program to Delete a New Node From the End of the Doubly Linked List
- Program to Delete a New Node From the Middle of the Doubly Linked List
- Program to Find the Maximum and Minimum Value Node From a Doubly Linked List
- Program to Insert a New Node at the Beginning of the Doubly Linked List
- Program to Insert a New Node at the End of Doubly Linked List
- Program to Insert a New Node at the Middle of Doubly Linked List
- Program to Remove Duplicate Elements From a Doubly Linked List
- Program to Rotate Doubly Linked List by N Nodes
- Program to Search an Element in a Doubly Linked List
- Program to Sort the Elements of the Doubly Linked List
- Program to Convert cm to Feet and Inches
- Program to Convert Feet to cm
- Program to Convert Feet to Inches
- Program to Convert Inches to cm
- Program to Convert Inches to Feet
- Program to Convert Kilometer to cm
- Pyramid Programs in VB
- Program to calculate Volume of Cone
- Write a Program to calculate the Perimeter of Hexagon
- Write a Program to calculate the Area of Rhombus
- Write a Program to calculate the surface Area of Cone
- Write a Program to calculate the Surface Area of Hemisphere
- Write a Program to find the Perimeter of Ellipse
- Write a program to calculate the Altitude of Isosceles Triangle
- Write a Program to calculate the Area of Isosceles Triangle
- Write a program to find the Volume of Tetrahedron
- Write a program to find the Area of an Icosahedron
- Write a program to find the Volume of Octahedron
- Write a program to find the Area of Tetrahedron
- Write a program to find the Surface Area of the Pentagonal Prism
- Write a program to find the Area of the Rectangular Prism
- Write a program to find the Surface Area of a Triangular Prism
- Write a Program to find the Area of Hexagonal Prism
- Write a Program to find the Volume of a Hexagonal Prism
- Write a program to find the Volume of the Rectangular Prism
- Program to Convert centimeter to millimeter
- Program to Convert centimeter to meter
- Program to Convert Feet to millimeter
- Program to Convert Meter to Centimeter
- Program to Convert mm to cm
- Program to Convert millimeter to Feet
- Program to Convert Feet to m
- Program to Convert Inches to meter
- Program to Convert Inches to mm
- Program to Convert m to Feet and Inches
- Write a program to calculate the Perimeter of a Rhombus
- Write a program to find the quotient and remainder
- Program to convert Kilobytes to bytes and bits
- Program to find the area and perimeter of the semicircle
- Program to find the area and perimeter of trapezium
- Program to find the type of triangle from the given coordinates
- Program to convert hours into minutes and seconds
- Program to convert temperature degree from Celsius to Kelvin
- Write a program to find the sum of even numbers

## Program to determine whether a given matrix is a sparse matrix## ExplanationIn this program, we need to check whether the given matrix is the sparse matrix. ## Sparse MatrixA matrix is said to be sparse matrix if most of the elements of that matrix are 0. It implies that it contains very less non-zero elements. To check whether the given matrix is the sparse matrix or not, we first count the number of zero elements present in the matrix. Then calculate the size of the matrix. For the matrix to be sparse, count of zero elements present in an array must be greater than size/2. Number of zeroes present in above matrix is 6 and size of the matrix is 3 * 3 = 9. Since, 6 > 4.5 that means, most elements of given array are zero. Hence, the above matrix is a sparse matrix. ## Algorithm- Declare and initialize a two-dimensional array a.
- Calculate the number of rows and columns present in the given array and store it in variables rows and cols respectively.
- Loop through the array and count the number of zeroes present in the given array and store in the variable count.
- Calculate the size of the array by multiplying the number of rows with many columns of the array.
- If the count is greater than size/2, given matrix is the sparse matrix. That means, most of the elements of the array are zeroes.
- Else, the matrix is not a sparse matrix.
## Solution## Python
Given matrix is a sparse matrix ## C
Given matrix is a sparse matrix ## JAVA
Given matrix is a sparse matrix ## C#
Given matrix is a sparse matrix ## PHP
Given matrix is a sparse matrix Next Topic# |

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks

G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India

© Copyright 2024 Javatpoint. All Rights Reserved.