1 / 32

Assignment 6 Sample problems

Assignment 6 Sample problems. Consider the following scratch program :. When the flag is clicked, how many times will the meow sound happen before everything stops? . When the flag is clicked, how many times will the meow sound happen before everything stops ? The answer is 11.

aimon
Télécharger la présentation

Assignment 6 Sample problems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assignment 6 Sample problems

  2. Consider the following scratch program:

  3. When the flag is clicked, how many times will the meow sound happen before everything stops? 

  4. When the flag is clicked, how many times will the meow sound happen before everything stops? The answer is11

  5. What value will num have at the end? 

  6. What value will num have at the end? The answer is 7

  7. How can we get ? In the beginning, num=5. Broadcast alpha actives receive alpha block, so keep broadcasting beta then active receive beta block, repeat 5 times. After repeat 5 times, change number by 1, so num=5+1=6, then continue broadcasting second alpha, do the same thing like before. so the number of meow sound is 5+6=11, num=6+1=7.

  8. Consider the following Scratch program:

  9. How many times does the meow sound play? 

  10. How many times does the meow sound play?  The answer is 3

  11. How many times does the sprite say "Hello!"? 

  12. How many times does the sprite say "Hello!"?  The answer is 2

  13. What is the value of the variable num when everything stops?

  14. What is the value of the variable num when everything stops? The answer is 3

  15. How can we get ? 1: Before broadcast, meow 1 time. In the first broadcasting, num increases from 1 to 3 without meowing. In the second of broadcasting, since num=3, meow twice. Therefore, the total number of meowing is 1+2=3. 2: whenever active receive block, say hello once. There are two broadcasts, say hello twice. 3: num=3

  16. The Catalan sequence is a series of numbers where the first number is C₀=1, and each subsequent number is Cₓ₊₁=(4x+2)Cₓ/(x+2). Thus, the sequence is 1, 1, 2, 5,………..

  17. Which of the following statements below expresses a base case? 1: C₀=1 2: C₁=1 3: C₂=2

  18. Which of the following statements below expresses a base case? 1: C₀=1 2: C₁=1 3: C₂=2

  19. Which of the following statements expresses the recursive step (i.e. dividing the problem into smaller subproblems)? 1: C₀=1 2: Cₓ₊₁=(4x+2)Cₓ/(x+2) 3: Cₓ₊₁= C₀+(4x+2)Cₓ/(x+2)

  20. Which of the following statements expresses the recursive step (i.e. dividing the problem into smaller subproblems)? 1: C₀=1 2: Cₓ₊₁=(4x+2)Cₓ/(x+2) 3: Cₓ₊₁= C₀+(4x+2)Cₓ/(x+2)

  21. Recall the Instruction Set and Processor we used in class: Translate the following machine language program into the list of binary instructions used by the computer: acc =acc and A acc=acc or D acc= not E

  22. Recall the Instruction Set and Processor we used in class: Translate the following machine language program into the list of binary instructions used by the computer: acc =acc and A 1010000 acc=acc or D 1000011 acc= not E 0110100

  23. Let the values of the variables be A=True, B=False, C= True and acc=True. What will be in the accumulator after each of the following programs are executed? acc = Bacc = acc and Aacc = acc or C

  24. Let the values of the variables be A=True, B=False, C= True and acc=True. What will be in the accumulator after each of the following programs are executed? acc = Bacc = acc and A acc = acc or C The answer is True

  25. How can we get ? • B and A or C so False and True or True=> True

  26. Let the values of the variables be A=True, B=False, C= True and acc=True. What will be in the accumulator after each of the following programs are executed? acc = acc and BC=accacc=not B acc= acc or C

  27. Let the values of the variables be A=True, B=False, C= True and acc=True. What will be in the accumulator after each of the following programs are executed? acc = acc and BC=accacc=not B acc= acc or C The answer is True

  28. How can we get ? • not B or (acc and B) so True or( True and False)=> True

  29. What will E be after each of these short machine-language programs are executed?  acc = not BE=accacc= AE = acc or E

  30. What will E be after each of these short machine-language programs are executed?  acc = not BE=accacc= AE = acc or E The answer is E=A or (not B)

  31. What will E be after each of these short machine-language programs are executed?  acc = A acc= acc or B E = acc  acc= not BE = acc and E

  32. What will E be after each of these short machine-language programs are executed?  acc = Aacc= acc or BE= acc acc= not BE = acc and E The answer is E=not B and (A or B )

More Related