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 2D 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 array-sorting
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 pro-hint: If you want to, you can implement different sorting algorithms and
calculate the exact run-time using System.nanoTime(), you could test a few input
values of n to average run-time.
Commenting/Documentation
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. In-line 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 in-line comment of an operation like i=i+1, 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 10% of your final grade (half as much as your midterm!). The
amount of code to be written is small, and most of the pseudo-code is in the lecture
notes or additional problem solution pdfs. Therefore, in addition to the well-written
code you are being graded on:
Compilation and basic function (5%) code must compile and print the
necessary matrices. Non-compliable code is heavily penalized.
Documentation (3%) well documented code is expected, including self-
documenting camelCase variable names.
Optimization (2%) optimized code is preferred but as this is the first
assignment you will not be graded harshly for non-optimal 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 optimal).Can 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 two-fold. 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 #2 and #3 to be released after the mid-term. Most of the pseudo-code
needed for this assignment is in the lecture slides or problem solutions on moodle.
Starter/Skeleton 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 2D 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 2D matrix
* prints: random left and right matrices, sorted left and right matrices, new matrix
*/
public static void main(String[] args)
{
int size = Integer.parseInt(args[0]);
//Implement rest of this method
}
}
randMatrix.java
/*
* Implementations for a Class that creates a 2D matrix of random numbers and performs sorting operations
* @author
*/
public class randMatrix
{
public int[][] matrix ;
boolean
randMatrix.java This class creates and holds a 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!