Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a recursive method that counts the number of creatures on a grid. An creat

ID: 3544891 • Letter: W

Question


Write a recursive method that counts the number of creatures on a grid. An creature is defined as a contiguous collection of 1's (connected horizontally and vertically).



Input


Max dimensions of the array


Distribution of organisms on the array



Output


The number of creatures and the layout of the grid showing the locations of the creatures.


Requirements checklist:


q Documented source code (include any assumptions you make)


Input File (in.txt)


The format of the input file is as follows: First line is the dimensions of the grid.. Then the grid containing 1s for the creatures and 0s for the spaces. The file terminates by 0 0.




5 5


0 0 0 0 0


0 1 1 1 0


0 0 0 0 0


0 0 0 0 0


0 0 0 0 0


5 5


0 0 0 0 1


0 1 1 1 0


1 0 0 0 0


0 0 0 0 0


0 0 0 0 0


0 0




Output File (out.txt)


Experiment # 1


Number of Creatures: 1


0 0 0 0 0


0 1 1 1 0


0 0 0 0 0


0 0 0 0 0


0 0 0 0 0




Experiment #2


Number of Creatures: 3


0 0 0 0 1


0 2 2 2 0


3 0 0 0 0


0 0 0 0 0


0 0 0 0 0




Explanation / Answer

HI


Try this it's tested worked pitch perfect :

// Creatures.java

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote