Datastructure Problems
Datastructure Problems
7: Tridiagonal matrix A
If the elements in the band formed by these three diagonals are represented rowwise
in an array, B, with
A (1,1) being stored at B(1), obtain an algorithm to determine the value of A(i,j),
1 i, j n from the
array B.
14. Define a square band matrix An,a to be a n x n matrix in which all the nonzero
terms lie in a band
centered around the main diagonal. The band includes a - 1 diagonals below and
above the main
diagonal and also the main diagonal.
file:///C|/E%20Drive%20Data/My
%20Books/Algorithm/DrD...ooks_Algorithms_Collection2ed/books/book1/chap02.htm (29
of 37)7/3/2004 4:01:13 PM
www.itdevelopteam.com
Fundamentals: CHAPTER 2: ARRAYS
a) How many elements are there in the band of An,a?
b) What is the relationship between i and j for elements aij in the band of An,a?
c) Assume that the band of An,a is stored sequentially in an array B by diagonals
starting with the
lowermost diagonal. Thus A4,3 above would have the following representation:
B(1) B(2) B(3) B(4) B(5) B(6) B(7) B(8) B(9) B(10) B(11) B(12) B(13) B
(14)
9 7 8 3 6 6 0 2 8 7 4 9 8
4
a31 a42 a21 a32 a43 a11 a22 a33 a44 a12 a23 a34 a13 a24
Obtain an addressing formula for the location of an element aij in the lower band
of An,a.
e.g. LOC(a31) = 1, LOC(a42) = 2 in the example above.
15. A generalized band matrix An,a,b is a n x n matrix A in which all the nonzero
terms lie in a band
made up of a - 1 diagonals below the main diagonal, the main diagonal and b - 1
diagonals above the
main diagonal (see the figure on the next page)
a) How many elements are there in the band of An,a,b?
b) What is the relationship between i and j for elements aij in the band of An,a,b?
c) Obtain a sequential representation of the band of An,a,b in the one dimensional
array B. For this
representation write an algorithm VALUE (n,a,b,i,j,B) which determines the value of
element aij in the
matrix An,a,b. The band of An,a,b is represented in the array B.