Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

Recommend the key methods to improve service productivity.

Answered: 1 week ago