0% found this document useful (0 votes)
24 views2 pages

Main Diagonal Side Diagonals Band (Width 7)

The document discusses storing and accessing different types of matrices using arrays including: - Band matrices where non-zero elements lie within a band of width 7 around the main diagonal. - Lower triangular matrices stored in a 1D array with the addressing formula for A[i,j]. - Storing two triangular matrices A and B in a 2D array C with addressing formulas for A[i,j] and B[i,j].

Uploaded by

adi6194
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Main Diagonal Side Diagonals Band (Width 7)

The document discusses storing and accessing different types of matrices using arrays including: - Band matrices where non-zero elements lie within a band of width 7 around the main diagonal. - Lower triangular matrices stored in a 1D array with the addressing formula for A[i,j]. - Storing two triangular matrices A and B in a 2D array C with addressing formulas for A[i,j] and B[i,j].

Uploaded by

adi6194
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

a=4

Main diagonal
Side diagonals
Band (width = 7)
Figure 1: Band matrix (width = 7) with 7 diagonals, 3 on ea h side of main diagonal.
IT-203 Data Stri tures and Algorithms
Tutorial Sheet: Arrays

1. Write elements of a C array A[3[2[3 in


(a) row-major order
(b) olumn-major order
2. Write a fun tion to multiply two sparse matri es. Ea h sparse matrix is stored in a one-dimensional array
of 3-tuples hrow, olumn, valuei in a row-major order.
3. Repeat previous exer ise when olumn-major order is used.
4. A polynomial A(x) = an xn + an 1 xn 1 +    + a1 x + a0 is represented by a one dimensional array of 2-tuple
h oe eint, exponenti. So a polynomial 5x7 + 2x5 + 3x + 2 is represented as
4
5
2
3
2

7
5
1
0

Write routines for


(a) Evaluating polynomial at x0
(b) Adding two polynomials
( ) Multiplying two polynomials
5. A lower triangular matrix A(A[i; j = 08i < j ) of size n  n and m = n(n + 1)=2 elements is to be stored
in an array B [1 : : : m with B [1 = A[1; 1. Determine addressing formula for A[i; j .
6. Two triangular matrix A and B , ea h of size n  n are stored in C [1 : : : n; 1 : : : n + 1. Devise a s heme to
store both A; B in C and obtain addressing formulas for A[i; j and B [i; j .
7. Obtain addressing formula for elements of a n-dimensional matrix
assuming
1

A l1

u1 ; l 2

u 1 ; l3

u3 ; : : : ; l n

un

(a) row-major order representation


(b) olumn-major order representation
8. A band matrix An;a is a n  n matrix in whi h non-zero terms lie in a band entered around main diagonal.
Band in ludes a total of 2a 1 diagonals in luding main diagonal, a diagonals above and a diagonals below
this main diagonal as illustrated in Figure 1. Obtain
(a) Number of elements in a band matrix An;a
(b) Obtain addressing formula for A[i; j if A is stored sequentially in an array B su h that only non-zero
terms of A are stored
i. row-wise
ii. olumn-wise
iii. diagonal-wise (lowermost diagonal rst and ea h diagonal stored from leftmost to rightmost element)
( ) relationship beteen i and j for non-zero elements.

You might also like