Test Corrections for Unit 2 Test

I put option C which is incorrect. In the simulation, the variable flip_counter represents the number of times a coin was flipped. When flip_counter equals 2, only two coins have been flipped. This information does not lead to knowledge about the result of the simulation. Option D is correct. It is because there are 4 trials in the simulation, and the goal is to determine if there were an equal number of head and tails, or, in other words, 2 heads. In Step 2, heads_counter is incremented when coin_flip represents heads. The simulation will result in an equal number of heads and tails if heads_counter = 2.

I put option C thinking that there would be an actual number that show up but since it was not defined when to stop, the number count would still infinitley go up and therefore there would be no number displayed because it is an infinite loop.

I put option D and this option is incorrect. Only one number should display. Option A is correct. The initial value of count is 1, which is less than 5. The variable count is incremented to 2, then 3, then 4, then 5. At this point the condition count < 5 is false, and the algorithm displays the value 5.

I put answer D, This option is incorrect. The value of the variable j starts at 1 and increases by 2. If is replaced with the expression j > 7, the expression will evaluate to true when j is 9 and the loop will end. Option A is correct. Because the value of the variable j starts at 1 and increases by 2, the value of j will always be odd. Thus the value of j will never equal 6. If is replaced with the expression j = 6, the expression will always evaluate to false, and the loop will never end.

I put answer C, this option is correct. After one iteration of the Repeat 2 times loop, the robot will end up in the upper-right square facing to the left. After the second iteration of the Repeat 2 times loop, the robot will end up in the upper-left square facing down. The robot has finished in the gray square. The other option I put was D, this option is incorrect. After completing the inner Repeat 2 times loop, the robot will be in the center square of the grid facing down. Since this loop is nested inside another Repeat 2 times loop, these commands are executed again. At the end of execution, the robot will be in the same position at which it started.

I put A, this option is incorrect. In program II, the value of i starts at n and finishes at 1, so that result stores the sum of n + (n - 1) + … + 3 + 2 + 1. This is the same as 1 + 2 + 3 + … + n. The answer C is correct. In program I, the value of i starts at 1 and finishes at n, so that result stores the sum of 1 + 2 + 3 + … + n. In program II the value of i starts at n and finishes at 1, so that result stores the sum of n + ( n - 1 ) + … + 3 + 2 + 1. Both programs display the correct sum.

I put answer A which is wrong. A was: When the problem can be solved in a reasonable time and an approximate solution is acceptable. The correct answer was C which is: When the problem cannot be solved in a reasonable time and an approximate solution is acceptable. This makes sense because a heuristic solution cannot be determined if not a lot of time is allotted to do so getting an approximation is better then doing it incorrect.

Reflection

Overall, I did this test with one of my friends and we tried to work together to figure out the questions and this helped a lot and even allowed me to learn new concepts because my friend taught me some things I was unaware of and I did the same with him. This coding gave me new things to learn and incorporate into my code and overall I think taking this test helped a lot. I learned the definition of heuristic solutions, how to deal with repeats and loops, and many other coding things that I can use when I try to code myself. The test took a long time also but there are a lot of different coding topics and languages that helped me and though the help of others, and looking up some of the answers to understand how to do certain things, I was able to take a lot from this experience and learn.