Question: Write me a code in the java lanaguage with these psusedocode instructions, also the only instance variable is: 'private char [ ] [ ] grid;

Write me a code in the java lanaguage with these psusedocode instructions, also the only instance variable is: 'private char[][] grid;'
Pseudocode for Algoritnm longestLine()
Algorithm longestLine()
// Scan first the rows of the grid from bottom to top
Create an object of the class Line representing a horizontal line starting at the first row and first column
of grid and of length 1. Store the address of this object in a variable called longLine.
largest =0
for each row i of the grid starting at the bottom and moving to the top do {
letter = letter at row i and leftmost column of the grid
adjacent =1
for each column j of the grid starting at the second one and moving to the right do {
if letter at row i and column j of the grid is equal to letter and letter blank space then {
increase adjacent
if adjacent is bigger than largest then {
largest = adjacent
longLine = new object of the class Line representing a horizontal line
starting at row i and column j-adjacent +1(Why this column?)
of length adjacent
}
}
else {
letter = letter at row i and column j of the grid
}
adjacent =1
}
// Now scan the columns from left to right; each column is scanned from the bottom to the top
for each column j of the grid starting at the leftmost one and moving to the right do {
letter = letter at the bottom row of the grid and column j
adjacent =1
for each row i of the grid from the second row from the bottom and moving to the top do
if letter at row i and column j of the grid is equal to letter and letter blank space then {
increase adjacent
if adjacent is bigger than largest then {
largest = adjacent
longline = new object of the class Line representing a vertical line
starting at row i and column j of length adjacent
}
}
else {
letter = letter at row i and column j of the grid
}
adjacent =1
}
if the length of longline is larger than 2 then return longline else return null
 Write me a code in the java lanaguage with these psusedocode

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 Databases Questions!