00:01
Hello student, the algorithm to fill in the grid for any input n is as follows.
00:06
Initialize the grid to be all empty squares.
00:09
So here grid is given to s and initialize all the squares with empty.
00:15
For each row and column starting from the top left corner and moving down to the right do the following.
00:22
So we are starting from the top left and moving down to the right.
00:26
So do the following.
00:27
If row and column are both even or both odd then fill in the square with a black square.
00:32
So black will be entered when rows and columns are even.
00:38
So here rows and here columns these both are even.
00:43
So both are even then enter black color.
00:47
After this otherwise fill the square with the white square.
00:51
Otherwise fill the white square.
00:52
Repeat the step 2 and 3 until the entire grid is filled with.
00:56
So this is entire grid will be filled.
00:59
Here is the pseudocode.
01:01
So first define fill underscore grid n.
01:06
So fill so i have declared the grid.
01:10
This is this will be n into n and here n into n will be the squares in the grid and at the starting all of these are empty.
01:21
So we have to fill the grid with black and white square according to the given algorithm.
01:25
So here argument n is the size of the grid.
01:28
Return a list of lists with each sub list represent a row in the grid and each element in the sub list represent a square.
01:37
So here rows will be as a sub list and these will be returns and here these represent a square.
01:45
The value of each element in the sub list is either 0 or 1.
01:49
So 0 for the white color and 1 for the black square.
01:53
So these will be returned and here grid 0 for j in the range n for j in the range n.
02:01
So here i have taken the loop for i 0 for i in the range.
02:05
So here i and j these are for rows and column.
02:10
So for i in a range n...