Question: import java.lang.reflect.Array; import java.util.ArrayList; public class LinkedGrid { protected int numRows; protected int numCols; protected GridNode head; protected GridNode lastRowHead; protected GridNode lastColHead; public LinkedGrid

import java.lang.reflect.Array; import java.util.ArrayList; public class LinkedGrid{ protected int numRows; protected int numCols; protected GridNode head; protected GridNode lastRowHead; protected GridNode lastColHead; public LinkedGrid(){}/* A constructor which takes the initial number of rows and columns of the LinkedGrid. This constructor needs to initialize the LinkedGrid with grid nodes (which are initially empty) Example: if I invoked the constructor with new LinkedGrid(2,3), then I would have to initialize my LinkedGrid of 6 empty nodes with 2 rows and 3 nodes per row */ public LinkedGrid(int numRows, int numCols){// TO DO this.numRows = numRows; this.numCols = numCols; createGrid(); }/*public GridNode handleEmptyGrid(){}*//* Constructor which takes a normal 2D array as an argument. This is the ONLY place you can use a 2D array and this 2D array is only used to initialize the values of your LinkedGrid object*/ public LinkedGrid(E[][] elements){// TO DO this.numRows = elements.length; this.numCols = elements[0].length; }/* Get the number of rows */ public int getNumRows(){ return numRows; }/* Get the number of columns */ public int getNumCols(){ return numCols; }/* Returns the item at the given (row, col). NOTE: You must return the item stored in the GridNode, NOT the GridNode itself */ public E get(int row, int col){ GridNode curr = head; for(int i =0; i curr = head; for(int i =0; i getRow(int index){ ArrayList rowValues = new ArrayList<>(getNumCols()); GridNode curr = head; for(int i =0; i getCol(int index){ ArrayList colVaules = new ArrayList<>(getNumRows()); GridNode curr = head; for(int i =0; i < index; i++){ curr = curr.nextCol; } for(int j =0; j

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!