answersLogoWhite

0


Best Answer

#include<stdio.h>

int main()

{

int a[20],min,max;

int n;

printf("\nEnter the num of elements: ");

scanf("%d",&n);

printf("Enter the elements\n");

for(int i=0;i<n;i++)

{

scanf("%d",&a[i]);

if(i==0)

{

min=max=a[i];

}

if(a[i]<min)

min=a[i];

else if(a[i]>max)

max=a[i];

}

printf("The largest element is %d. The smallest element is %d.", max, min);

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How sparse matrix can be stored using array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How is sparse matrix stored in the memory of a computer?

A sparse matrix contains many (often mostly) zero entries. The basic idea when storing sparse matrices is to only store the non-zero entries as opposed to storing all entries. Depending on the number and distribution of the non-zero entries, different data structures can be used and yield huge savings in memory when compared to a na&iuml;ve approach. One example of such a sparse matrix format is the (old) Yale Sparse Matrix Format [1]. It stores an initial sparse N&times;N matrix M in row form using three arrays, A, IA, JA. NZ denotes the number of nonzero entries in matrix M. The array Athen is of length NZ and holds all nonzero entries of M. The array IA stores at IA(i) the position of the first element of row i in the sparse array A. The length of row i is determined by IA(i+1) - IA(i). Therefore IA needs to be of length N + 1. In array JA, the column index of the element A(j) is stored. JA is of length NZ. Another possibility is to use quadtrees


What are disadvantages of sparse matrix in data structure using c?

what is the disadvantage of sparse matrix?


How do you find matrix in c?

using multidimensional array


Is it possible to print matrix without using array?

Yes but why.


Algorithm of augment matrix a of order nn 1 stored using two dimensional array of size nn 1the solution of system of linear equation is stored in one dimensional array name x of size n?

Please use the discussion area to state your question in English.


How do you represent binary tree using array?

The root of the tree is stored in array element [0]; for any node of the tree that is stored in array element [i], its left child is stored in array element [2*i], its right child at [2*i+2]


What is a fast-transpose algorithm for sparse matrices?

A fast-transpose is a computer algorithm that quickly transposes a sparse matrix using a relatively small amount of memory. Using arrays normally to record a sparse matrix uses up a lot of memory since many of the matrix's values are zero. In addition, using the normal transpose algorithm to transpose this matrix will take O(cols*elements) amount of time. The fast-transpose algorithm only uses a little memory to record the matrix and takes only O(cols+elements) amount of time, which is efficient considering the number of elements equals cols*rows.


If a CBT is stored using array , then what is the parent node of element stored at index 11?

In a complete binary tree (CBT) stored using an array, the parent of an element at index i can be found at index (i-1)/2, assuming the array is 0-indexed. So for an element stored at index 11, the parent node would be stored at index (11-1)/2 = 5.


What are Advantages of using gate array in digital design?

The advantages of using an array are that lists of the same data types can be stored easily without the need for a connection to a database. For example, a list of names can be stored in an array and only one variable need be declared. - Mike Hoerger


How do you add two matrices using Linux shell script?

write ashell script to add awo matrix using array.


What will be the program to arrange numbers stored in array in ascending order using pointers?

sorry


How matrices can be represented using two dimensional array?

You've pretty much answered your own question because a two-dimensional array is a matrix. Indeed, all multi-dimensional arrays are matrices. When we create a matrix, we generally know what type of data will be stored in the matrix, how many dimensions it will have and how many elements each dimension will have, thus an array is the ideal container to represent a matrix. It provides the most compact method of storing homogeneous data, provides efficient constant-time random access to the data and introduces the least amount of abstraction into the representation. Most languages do not provide a built-in matrix type, however this is simply because there is no one matrix type that would suit every possible application. However, all languages do provide a built-in array mechanism which can be used as the basis for any matrix type which is both simple to create and easy to maintain.