Generate a sparse vector class with operator such as


Language is C++

Generate a sparse vector class with * operator, such as 

Vector Vector::operator * (Vector& param)

A multiplication (*) operators returns element-wise multiplication of two vectors in another vector. Given two sparse vectors, A and B, and a result vector C, and C = A * B,

Cn = An * Bn

where Sn notates nth items in the sparse vector.

In the main(), demonstrate the * operator. Basically, create vector A and B with size 10. Add 4 non-zero items at random locations in A and add 7 non-zero items at random locations in B. Then C = A * B and show all elements of vector C.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Generate a sparse vector class with operator such as
Reference No:- TGS02927489

Now Priced at $10 (50% Discount)

Recommended (97%)

Rated (4.9/5)