Question: Matrix ADT Specifications In addition to the main program Sparse.java and the altered List.java from pal, you will implement a Matrix ADT in a file


Matrix ADT Specifications In addition to the main program Sparse.java and the altered List.java from pal, you will implement a Matrix ADT in a file called Matrix.java, which defines the Matrix class. This class will contain a private inner class (similar to Node in your List ADT) that encapsulates the column and value information corresponding to a matrix entry. You may give this inner class any name you wish, but I will refer to it here as Entry Thus Entry will have two fields that store types int and double respectively. Entry must also contain its own equals) and toString() methods which override the corresponding methods in the Object superclass Your Matrix class will represent a matrix as an array of Lists of Entry Objects. It is required that these Lists be maintained in column sorted order. Your Matrix ADT will export the following operations // Constructor Matrix (int n) // Makes a new n x n zero Matrix. pre : n>=1 // Access functions int getsize // Returns n, the number of rows and columns of this Matrix int getNNZ // Returns the number of non-zero entries in this Matrix public boolean equals (Object x) // overrides Object's equals) method // Manipulation procedures void makeZero) // sets this Matrix to the zero state Matrix copy ) // returns a new Matrix having the same entries as this Matrix void changeEntry(int i, int j, double x) /1 changes ith row, jth column of this Matrix to x // pre : 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
