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} \]

Figure 1: Eye Pattern Array (5x5). The diagonal cells are set to 1, and the rest are set to 0. The positions are indexed starting from 0, for example, the first value is in position (0,0), the second in (1,1), and so on.

The function draw_eye_array should read the dimension N and generate the array.

TipSetting list values

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:

  1. Flowchart in Figure 2 (a)
  2. Flowchart in Figure 2 (b)
  3. Flowchart in Figure 2 (c)
  4. 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 --> 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))
(a)
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))
(b)
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))
(c)
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))
(d)
Figure 2: Alternative flowcharts for the algorithm to generate an eye pattern array in a 2D list.