Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Recursion count marks Please write NEW code in java. Dont use answers from other questions, please write NEW CODE to do the following: Write a
Recursion count marks
Please write NEW code in java. Dont use answers from other questions, please write NEW CODE to do the following:
Write a code to traverse a matrix to count how many "?" marks are grouped. A group is when all the ? marks are touching up, left, down, and right. NOT diagonally. A comma is used to represent a blank space in the matrix.
here is the code given:
int start(String m, String c) {
String[][] mat;
boolean[][] visited;
//code goes here
}
String m contains the symbols of ? and ,
String c contains the coordinates.
String m is
,,,,,,,,,, ,,,??????? ???,,,,??, ?,,,,,,??? ,,,,,????, ???,,,,,,, ???????,,, ???,,,,,?? ,,,,,,,,,, ,,,,,????,
The spaces resemble where one row stops and the next begins so it would look like
, , , , , , , , , ,
, , , ???????
???, , , , ??,
?, , , , , , ???
, , , , , ????,
???, , , , , , ,
???????, , ,
???, , , , , ??
, , , , , , , , , ,
, , , , , ????,
String c is
1 1 2 7 2 0 6 6
The output is:
0
16
4
13
Iterate through string m and store it in the matrix. You can store the coordinates in a matrix with two columns, if you want.
Please keep the code as simple and short as possible (beginner recursive)
Please use the code given
int start(String m, String c) {
String[][] mat;
boolean[][] visited;
//code goes here
}
Please try to keep the code in the start class.
Make sure the code prints:
0
16
4
13
Thanks!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started