Question: Do it in c++ using oop techniques. Question #1: Example: n x m = 7 x 9 3 1 0 2 1 0 0 Question:

 Do it in c++ using oop techniques. Question #1: Example: n

Do it in c++ using oop techniques.

Question #1: Example: n x m = 7 x 9 3 1 0 2 1 0 0 Question: What is Sparse Matrix? In computer programming, a matrix can be defined with a 2-dimensional array. Any array with 'm' columns and 'n' rows represents a n Xm matrix. There may be a situation in which a matrix contains a greater number of ZERO values than NON-ZERO values. Such matrix is known as sparse matrix. oooo OOOS 1 o 004 0 0 0 ololololo 0 0 0 0 ol 0 0 0 0 0 0 0 0 0 0 0 0 2 0 ololo 0 2 0 0 4 8 0 0 0 We can store these sparse matrices using less memory, by storing only non-zero entries rather than storing all entries. Consider two sparse matrices of size:3x7. Sparse Matrix # 1 3 0 0 1 0 Sparse Matrix # 2 0 1 0 0 0 0 2 0 8 0 0 9 0 0 0 0 0 0 0 0 0 0 0 7 12 9 0 8 2 8 7 3 0 0 2 0 0 The above sparse matrices will be stored in compact matrices, shown as below. No. of Column Value Column Value Row elements index index Compact 0 2 0 3 3 1 Matrix #1 1 1 2 9 2 6 0 7 1 12 2 9 4 8 5 2 6 8 Row Value Value value No. of elements Compact Matrix #2 Column index 3 Column index 4 Column index 6 1 2 8 0 1 2 0 3 0 7 1 3 4 2 Note: You are required to only allocate exact size of memory. To implement the idea of storing the sparse matrix into a compact matrix, you need to implement the class of CompactMatrix. CompactMatrix will have two data members, rows (int), mat (int **). You need to implement the required functionalities: 1. Constructors: Which receives a sparse matrix and stores in mat (int **) in compressed/compact form. (20) 2.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!