Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a class template SparseMat? which implements a sparse matrix?. Use FHvector? and FHlist?, only, as base ADTs on which to build your class. Your

Design a class template SparseMat? which implements a sparse matrix?. Use FHvector? and FHlist?, only, as base ADTs on which to build your class. Your primary public instance methods will be: ? SparseMat(int r, int c, const Object & defaultVal)? - A constructor that establishes a size (row size and column size both > 1) as well as a default value for all elements. ? const Object & get(int r, int c) const? - An accessor that returns the object stored in row r? and column c?. It throws a user-defined exception if matrix bounds (row and/or column) are violated. ? bool set(int r, int c, const Object &x)? A mutator that places x? in row r? and column c?. It returns false? without an exception if bounds are violated. Also, if x is the default value it will remove any existing node (the internal data type used by SparseMat?) from the data structure, since there is never a need to store the default value explicitly. Of course, if there is no node present in the internal data representation, set()? will add one if x? is not default and store x? in it. ? void clear() ?- clears all the rows, effectively setting all values to the defaultVal (but leaves the matrix size unchanged). ? void showSubSquare(int start, int size)? - a display method that will show a square sub-matrix anchored at (start, start)? and whose size is size x size?. In other words it will show the rows from start? to start + size -1? and the columns from start? to start + size - 1?. This is mostly for debugging purposes since we obviously cannot see the entire matrix at once. Here is a sample main()? that will test your template. However, this does not prove that you are correctly storing, adding and removing internal nodes as needed. You'll have to confirm that by stepping through your program carefully. You main should also print the upper left and lower right of the (huge) matrix, so we can peek into it.

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_2

Step: 3

blur-text-image_3

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 Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Identify sustainable HRM practices in an organization.

Answered: 1 week ago

Question

1. What are the major sources of stress in your life?

Answered: 1 week ago