Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

1 2 . : -

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago