Question: User write the java program: suppose there is a n * n 2 d array, write a method that finds the neighboor of one particular

User
write the java program: suppose there is a n*n 2d array, write a method that finds the neighboor of one particular point in the array, each point have 8 neighboors, there neighboors are horizontally, vertically, or diagonally adjacent. For example, if it's a 4*4 array, when the point is (2,1), it's neighboors are (1,1),(3,1)(2,0),(2,2)(1,0),(1,2),(3,0),(3,2). when the point is (1,3), the neighboors are (0,3),(2,3),(1,2),(1,0),(0,0),(0,2),(2,0),(2,2), when the point is (0,0) the neighbor is (1,0),(3,0)(0,1),(0,3)(1,1),(1,3),(3,1),(3,3)Cells
Each cell can be in one of two states, alive or dead, and it has 8 neighboring cells which are the cells that are horizontally, vertically, or diagonally
adjacent. The figure below exemplifies neighboring cells on a game board of 44 cells.
Cell at row 2, column 1 neighbors:
Vertical: (1,1),(3,1)
Horizontal: (2,0),(2,2)
Diagonal: (1,0),(1,2),(3,0),(3,2)
Cell at row 1, column 3 neighbors:
Vertical: (0,3),(2,3)
Horizontal: (1,2),(1,0)
Diagonal: (0,0),(0,2),(2,0),(2,2)
Cell at row 0, column 0 neighbors:
Vertical: (1,0),(3,0)
Horizontal: (0,1),(0,3)
Diagonal: (1,1),(1,3),(3,1),(3,3)
 User write the java program: suppose there is a n*n 2d

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!