Question: Write a function to flood fill a region of a two-dimensional array. Given a two dimensional array of characters containing the characters x and o

Write a function to flood fill a region of a two-dimensional array. Given a two dimensional array of characters containing the characters x and o and a starting row and column location; change all the four connected locations accessible from the starting location from o to x. A four connected set of locations is accessible by moving up, down, left or right from the starting location, only entering squares containing o characters (i.e. you cannot move in a diagonal direction). Locations in the array are zero-based, and begin in the upper-left corner (i.e. the upper left position is [0, 0]). You may assume that the array contains a border of x characters and the starting location always contains an o.

The function prototype is:

Java:

public static void floodFill( char array[][], int startRow, int startColumn );

please write the program in java

input:

Assume the 5x15 array contains:

xxxxxxxxxxxxxxx

xxooooxooooxxxx

xxxxoooxxooxxxx

xxxooxxxxooooxx

xxxxxxxxxxxxxxx

output:

After calling floodFill the array should contain (boldface shown to help you identify changed items):

xxxxxxxxxxxxxxx

xxxxxxxooooxxxx

xxxxxxxxxooxxxx

xxxxxxxxxooooxx

xxxxxxxxxxxxxxx

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!