graph LR
A((Start)) --> B[/"N"/]
B --> R["Set<br>row = 0"]
R --> C{"Is<br>row > N?"}
E -- No --> J["Increment<br>row by 1"]
C -- No --> E{"Is<br>col > N?"}
E -- Yes --> EYE{"Is<br>row<br>equal to<br>col?"}
EYE -- Yes --> F[/"array[row][col] = 1"/]
EYE -- No --> G[/"array[row][col] = 0"/]
F --> I["Increment<br>col by 1"]
J --> C
G --> I
I --> E
C -- Yes --> L((End))
Eye array drawing algorithm
Which of the following flowcharts correctly represents the algorithm of a function called draw_eye_array that generates a symmetrical array (eye pattern) in a 2D list?
The algorithm should create a square array of size N x N and set the value of the diagonal cells to 1 and the rest to 0.
For example, for a 5x5 array, the output should be:
\[ \begin{array}{ccccc} 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{array} \]
The function draw_eye_array should read the dimension N and generate the array.
Consider that the command array[row][col] = 1 sets the value of the cell in the row and col position to 1. For example, array[0][0] = 1 sets the value of the first cell to 1.
Select the correct flowchart from the following options:
- Flowchart in Figure 2 (a)
- Flowchart in Figure 2 (b)
- Flowchart in Figure 2 (c)
- Flowchart in Figure 2 (d)
graph LR
A((Start)) --> B[/"N"/]
B --> R["Set<br>row = 0"]
R --> C{"Is<br>row >= N?"}
E -- No --> J["Increment<br>row by 1"]
C -- No --> D["Set<br>col = 0"]
D --> E{"Is<br>col >= N?"}
E -- Yes --> EYE{"Is<br>row<br>equal to<br>col?"}
EYE -- Yes --> F[/"array[row][col] = 1"/]
EYE -- No --> G[/"array[row][col] = 0"/]
F --> I["Increment<br>col by 1"]
J --> C
G --> I
I --> E
C -- Yes --> L((End))
graph LR
A((Start)) --> B[/"N"/]
B --> R["Set<br>row = 0"]
R --> C{"Is<br>row > N?"}
E -- No --> J["Increment<br>row by 1"]
C -- No --> D["Set<br>col = 0"]
D --> E{"Is<br>col > N?"}
E -- Yes --> EYE{"Is<br>row<br>equal to<br>col?"}
EYE -- Yes --> F[/"print(1)"/]
EYE -- No --> G[/"print(0)"/]
F --> I["Increment<br>col by 1"]
J --> C
G --> I
I --> E
C -- Yes --> L((End))
graph LR
A((Start)) --> B[/"N"/]
B --> R["Set<br>row = 0"]
R --> C{"Is<br>row >= N?"}
C -- No --> D["Set<br>col = 0"]
D --> E{"Is<br>col >= N?"}
E -- Yes --> J["Increment<br>row by 1"]
E -- No --> EYE{"Is<br>row<br>equal to<br>col?"}
EYE -- Yes --> F[/"array[row][col] = 1"/]
EYE -- No --> G[/"array[row][col] = 0"/]
F --> I["Increment<br>col by 1"]
J --> C
G --> I
I --> E
C -- Yes --> L((End))