4. (1 pt) In our flu virus simulation, the update function takes the current mat
ID: 3701639 • Letter: 4
Question
4. (1 pt) In our flu virus simulation, the update function takes the current matrixrepresenting the health states of the population and computes and returns a new matrix of the health states of the population for the next day. Note that we created an entirely new matrix; we didn't reuse the current matrix. What subtle logical error occurs if we were to reuse the current matrix instead, as shown below (changes in red)? Answer this question by considering the case where the last person in the population is healthy and contacts four people that were healthy in the original matrix that is passed into the def update (matrix): # create next day for i in range (0,20): for j in range (0,20): if immune (matrix, i, j): elif infected (matrix, i, j) or contagious (matrix, i, j): elif healthy (matrix, i, j): matrix[1 ] [ j ] = IMMUNE matrix[ij)-matrix[ 1 for k in range(0,4): # repeat 4 times # pick a random person at position random x and y random x - randint (0,19) random y randint( if contagious (matrix, randomx, random y): matrix [ ? ] [ j ] INFECTED return matrixExplanation / Answer
Answer:
When the last person contacts 4 random healthy people, they may have changed their states from healthy to contagious in the present matrix, since it gets updated in the same matrix, whereas had we used a new matrix, the last healthy person would contact 4 healthy person and they wouldn't have changed their state and the last person remains healthy, which is logically correct.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.