Question: randMatrix.java This class creates and holds a 2 D matrix object. This object is assigned random values in the constructor which is called by the
randMatrix.java
This class creates and holds a D matrix object. This object is assigned random values
in the constructor which is called by the main function of matrixMul.java when the
object is created. This class also contains sortMat, that uses the arraysorting
algorithm from the sortAlg.java class below on the rows or columns of the matrix.
sortAlg.java
This class defines a sorting algorithm optimized for randomly generated arrays.
Implement the sorting algorithm that you think is optimal here. It is used by the
randMatrix class. It contains only two methods, a sortA method recursively sorts an
array, and a helper method to perform any external functions the algorithm may need.
These methods are static, so they do not require an instance of this class to be created.
Bonus prohint: If you want to you can implement different sorting algorithms and
calculate the exact runtime using System.nanoTime you could test a few input
values of to average runtime.
CommentingDocumentation
Header comments have been provided for every class and method. Everyone must
replace author name with their own name. You can add a line to the header
comments to describe what type of algorithm you implemented. Inline comments are
required to document what parts of your code do Write them at your discretion. For
example, you do not need to write an inline comment of an operation like but
you should be writing one for different levels of a nested loop. Your code will be
evaluated on the quality of documentation.
Output
The driver code matrix Mul.java needs to print the following:
lefMatrix and righ Matrix with random numbers are initialized.
Sorted leftMatrix and rightMatrix after sorting as described above.
Final Matrix after multiplication. Grading:
This assignment is worth of your final grade half as much as your midterm! The
amount of code to be written is small, and most of the pseudocode is in the lecture
notes or additional problem solution pdfs Therefore, in addition to the wellwritten
code you are being graded on:
Compilation and basic function code must compile and print the
necessary matrices. Noncompliable code is heavily penalized.
Documentation well documented code is expected, including self
documenting camelCase variable names.
Optimization optimized code is preferred but as this is the first
assignment you will not be graded harshly for nonoptimal algorithms. I hope
this encourages everyone to try the problem on their own using lecture notes
instead of looking for optimal solutions online many of which are not optimalCan you please help me asap and please be sure that the code outputs the correct matrix.. Overview
The goal of this first programming assignment is twofold. First, to give you a basic
introduction to programming the algorithms discussed in class. Second, to give you a
chance to get comfortable with programming in Java for the more complicated
Assignments # and # to be released after the midterm. Most of the pseudocode
needed for this assignment is in the lecture slides or problem solutions on moodle.
StarterSkeleton Code
This document is accompanied by starterCode.zip, which includes three java files,
described below. Each of these files contains a skeleton code to provide you a starter
point. Mainly just the class structure and comments.
matrixMul.java
This is the main java file for this assignment. It contains a single driver method. The
user inputs a single input, a number that defines the size n of a square matrix. Your
code must create two matrices "lefiMatrix" and "rightMatrix" filled with randomly
generated elements using randMatrix.java below. You then sort the rows in the
lefiMatrix, as in every element in a row must be sorted like this
and sort the columns of "rightMatrix" as below
Note, only one row and column are highlighted but each is sorted.
Then you multiply the two matrices to create a third square matrix of size n You may
at your discretion add more methods if you think they optimize your code.
matrixMul.java
Implementations for the driver matrix multiplication method
@author
public class matrixMul
This driver creates two D matrices of randMatrix class from the user input size
it then sorts left matrix rows and right matrix columns
then it multiplies left matrix with the right matrix and saves it as new D matrix
prints: random left and right matrices, sorted left and right matrices, new matrix
public static void mainString args
int size Integer.parseIntargs;
Implement rest of this method
randMatrix.java
Implementations for a Class that creates a D matrix of random numbers and performs sorting operations
@author
public class randMatrix
public int matrix ;
boolean
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
