Question: Java : perimeterof method required Complete the method called perimeterOf(int r, int c) which should return an integer representing the perimeter of the part which
Complete the method called perimeterOf(int r, int c) which should return an integer representing the perimeter of the part which starts at the given (r.c) point. The method MUST be done recursively without loops, otherwise you will receive 0 marks for this part. For example, in the image (A) shown above, the perimeter is 36 (which is the red border length, not the number of black cells on the border) and in image (B) it is 106. As for the other two images, it depends where you started expanding from. (hints: You will need to mark pixels as being visited (perhaps use another 2D array) Make sure not to re-visit these pixels. Also, make sure to handle borders correctly. A black pixel on a the topft border corner, for example, will add 2 to the perimeter count for the top and the left.) Complete the method called perimeterOf(int r, int c) which should return an integer representing the perimeter of the part which starts at the given (r.c) point. The method MUST be done recursively without loops, otherwise you will receive 0 marks for this part. For example, in the image (A) shown above, the perimeter is 36 (which is the red border length, not the number of black cells on the border) and in image (B) it is 106. As for the other two images, it depends where you started expanding from. (hints: You will need to mark pixels as being visited (perhaps use another 2D array) Make sure not to re-visit these pixels. Also, make sure to handle borders correctly. A black pixel on a the topft border corner, for example, will add 2 to the perimeter count for the top and the left.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
