CS计算机代考程序代写 Answer Book

Answer Book

Question 1.

Examine the code you have typed in, and explain how this code works. That is, why it produces two threads that print once per second and once every two seconds.

Question 2a.

Run the code with the following values of “n”, recording whether you get the correct result:

n = 10, Correct: Y / N
n = 1000, Correct: Y / N
n = 1000000, Correct: Y/ N
n = 10000000, Correct: Y/N

Question 2b.

Some of the answers in 2a are incorrect. Explain why you get incorrect results.

Question 3.

t3.py now shows the correct result even for large n. Explain, using the idea of queues, how this program works to give the correct result. You may Google for what queues are.

Question 4.

Since p1.py and t1.py are essentially the same program, they should produce the same results, but do not. Explain why.

Question 5.

Detail the changes you made to p1.py to make it give the same results at t1.py below and explain why it works.