Question: Flood fill without recursion: Consider an array similar to the one given below, we can see that the 1s in the matrix is forming a

Flood fill without recursion: Consider an array similar to the one givenFlood fill without recursion: Consider an array similar to the one given below, we can see that the 1s in the matrix is forming a closed contour. In a flood fill operation the user gives a point as the seed point, for example any location (x, y), say (6, 10), can be the seed point. The flood fill algorithm must fill the entire region inside the closed contour of 1s. However if 1s are not forming a closed contour the entire matrix becomes 1s (called as leakage). If the seed point is chosen outside the contour of 1s, then outer region of the contour must be filled with 1s. (either 4-Neighbourhood or 8-Neighbourhood elements can be considered)

SUBJECT: DATA STRUCTURES [CSE 2103] Assignment 3 Instructions: Refer to the Coding Standards attached with this Question Paper Avoiding Plagiarism while writing the code. Submission guidelines will be circulated shortly (xy-1) 8-neighbourhood Maze problem: A binary matrix is given say B, the task is to find sequence of moves from a given initial location (Xn, Yo) in the matrix, to a final location (Xo. Y) explicitly using stack. [ (0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0,0, Ex: Intial Location (Xn, Yo) = (0, 2) 0,0,1, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 1,1, 0, 0, 0,0, 0,0,1, 0, 0, 0,0, 0, 0, 0, 0, 0,0, 0, 0, 1, 0, 0, 0,0, 0,0,1, 0, 0, 0,0, 0, 0, 0, 0, 0,0,0, 0,1,1, 0, 0,0), t0, 0, 1, 0, 0,0,0, 0, 0,0, 0, 0,0, 0, 0, 0, 1, 0,0,0 t0,0, 1, 0, 0,0,0, 0, 0,0, 0, 0,0, 0, 0, 0, 1, 0,0,0) 0 0 0 0 0 01 0 0 0 0 0 010 Final Location (X %)=(7,4) 1. t0,0, 0, 0, 0,0,0,1 0,0, 0, 0,0,0, 0, 1, 0, 0,0,0 t0,0, 0, 0, 0,0,0,1, 0,0, 0, 0,0,0, 0, 1, 0, 0,0,01 0,0, 0, 0, 0,0,0,1,1,1,0, 0,0,0, 0, 1, 0, 0,0,01 0 0 1 01 The initial position Xa, Yo has 1 as the element. A move can be made to a location; only if there is 1 in the neighboring co-ordinate (only 4- neighbors are considered ignoring diagonal neighbors). In the above example from initial location (0,2) the possible move is (1,2). From (1, 2) the possible moves are (0,2), (13), (1,1) and (2,2). So the expected output for the input (0,2) as start and (7,4) 0,0, 0, 0, 0,0,0, 0, 0,0, 0,0,0,0, 0, 0, 0, 0,0,01 Expected result on selectin (6,10) as a seed point is given as as the destination is, a sequence 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0 There can be similar other paths. an array similar to the one g iven below, we can see that the Flood fiil without recursion: Consider 1's in the matrix is forming a elosed contour. In a flood fill operation the user gives a point as the seed point, for example any location (x, y) say (6, 10), can be the seed point. The flood fill algorithm mll the entire region inside the closed contour of 1's. However if 1's are not forming 2. a closed contour the entire matrix becomes 1's (called as leakage). If the seed point is chosen outside the contour of 1's, then outer region of the contour must be filled with 1's. (either 4- Neighbourhood or 8-Neighbourhood elements can be considered) ample of four neighborhood and eight nei 0,0, 0, 0, 0,0,0, 0, 0,0, 0,0,0, 0, 0, 0, 0, 0,0,0

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!