Question: 2. Suppose you are given an n n grid, some of whose squares are colored black and the rest white. Describe and analyze an algorithm

2. Suppose you are given an n n grid, some of whose squares are colored black and the rest white. Describe and analyze an algorithm to determine whether tokens can be placed on the grid so that every token is on a white square every row of the grid contains exactly one token; and every column of the grid contains exactly one token. | An example grid with a proper placement of tokens Your input is a two dimensional array IsWhite[1 .. n][1.. n] of booleans, indicating which squares are white. Your output is a single boolean. For example, given the grid above as input, your algorithm should return TRuE. [Hint: Compute a maximum matching in an appropriate bipartite graph. What pairs of objects are you trying to match, and how do you know if you can match them? Be sure to give your running time in terms of n. You really should learn to solve this type of problem.] 2. Suppose you are given an n n grid, some of whose squares are colored black and the rest white. Describe and analyze an algorithm to determine whether tokens can be placed on the grid so that every token is on a white square every row of the grid contains exactly one token; and every column of the grid contains exactly one token. | An example grid with a proper placement of tokens Your input is a two dimensional array IsWhite[1 .. n][1.. n] of booleans, indicating which squares are white. Your output is a single boolean. For example, given the grid above as input, your algorithm should return TRuE. [Hint: Compute a maximum matching in an appropriate bipartite graph. What pairs of objects are you trying to match, and how do you know if you can match them? Be sure to give your running time in terms of n. You really should learn to solve this type of problem.]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
