## Question 1 What should be the output if the following input is given? `nums` = [-4, 5, 4, -4, 4, 6, 7, 20] `w` = 2 ### Options 1. [5, 4, 6, 20] Incorrect Since the windows will overlap, the number of windows is $8 - 2 + 1 = 7$. ---------------------------- 2. [5, 20] Incorrect $2$ is not the number of windows but the size of each window. ---------------------------- 3. [5, 5, 4, 4, 6, 7, 20] Correct The first window of size $2$ is [-4, 5] and the maximum in this window is 5. The second window of size $2$ is [5, 4] and the maximum in this window is also 5. The third window of size $2$ is [4, -4] and the maximum in this window is 4. The fourth window of size $2$ is [-4, 4] and the maximum in this window is also 4. The fifth window of size $2$ is [4, 6] and the maximum in this window is 6. The sixth window of size $2$ is [6, 7] and the maximum in this window is 7. The final window of size $2$ is [7, 20] and the maximum in this window is 20. ---------------------------- 4. [5, 5, 4, 6, 6] Incorrect The number of windows should be $8 - 2 + 1 = 7$. ---------------------------- --------------------------------------------- ## Question 2 What should be the output if the following input is given? `nums` = [-4, 5, 4, -4, 4 , 6, 7] `w` = 10 ### Options 1. [] Incorrect ---------------------------- 2. [7] Correct Since the window size is greater than the size of the list, we will consider the size of the list as the window size, which is $7$. The first and only window of size $7$ is [-4, 5, 4, -4, 4 , 6, 7], and the maximum in this window is 7. ---------------------------- 3. [-4, 5, 4, -4, 4 , 6, 7] Incorrect ---------------------------- 4. [5, 4, 6, 7] Incorrect ---------------------------- --------------------------------------------- ## Question 3 What should be the output if the following input is given? `nums` = [3, 3, 3, 3, 3, 3] `w` = 3 ### Options 1. [3, 3, 3, 3] Correct The first window of size $3$ is [3, 3, 3], and the maximum in this window is 3. The second window of size $3$ is [3, 3, 3], and the maximum in this window is also 3. The third window of size $3$ is [3, 3, 3], and the maximum in this window is also 3. The fourth and the last window of size $3$ is [3, 3, 3], and the maximum in this window is also 3. ---------------------------- 2. [3, 3, 3] Incorrect ---------------------------- 3. [3, 3] Incorrect ---------------------------- 4. [3] Incorrect ---------------------------- --------------------------------------------- ## Question 4 What should be the output if the following input is given? `nums` = [1, 2, 3, 1, 4, 5, 2, 3, 6] `w` = 3 ### Options 1. [2, 3, 5, 3] Incorrect ---------------------------- 2. [3, 2, 4, 5, 5, 6] Incorrect ---------------------------- 3. [3, 3, 4, 5, 5, 5, 6] Correct The first window of size $3$ is [1, 2, 3], and the maximum in this window is 3. The second window of size $3$ is [2, 3, 1], and the maximum in this window is also 3. The third window of size $3$ is [3, 1, 4], and the maximum in this window is 4. The fourth window of size $3$ is [1, 4, 5], and the maximum in this window is 5. The fifth window of size $3$ is [4, 5, 2], and the maximum in this window is also 5. The sixth window of size $3$ is [5, 2, 3], and the maximum in this window is also 5. The seventh and the last window of size $3$ is [2, 3, 6], and the maximum in this window is $6$. ---------------------------- 4. [1, 2, 3, 1, 4, 5, 2] Incorrect ---------------------------- ---------------------------------------------