Please complete this Java class which uses LinkedLists to calculate Matrix arith
ID: 3744206 • Letter: P
Question
Please complete this Java class which uses LinkedLists to calculate Matrix arithmetic
public class Matrix<T> {
private Node start;
private class Node<T> {
private Node right;
private Node down;
private T item;
}
public T get(int row, int column) { //complete this method please....
// from `start`
// traverse down `row` number of rows
// traverse right `column` number of columns
Node<T> goal = ?
return goal.item;
}
public void set(int row, int column, T item) { //complete this method please
// from `start`
// traverse down `row` number of rows
// traverse right `column` number of columns
Node<T> goal = ?
goal.item = item; }
}
Explanation / Answer
public class Matrix { private Node start; private class Node { private Node right; private Node down; private T item; } public T get(int row, int column) { //complete this method please.... // from `start` // traverse down `row` number of rows // traverse right `column` number of columns Node goal = start; for(int i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.