DOC PREVIEW
Berkeley CS 61A - Fall 2009 Paper Midterm

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

cs39n_2009_fall_midterm_extraCS39n - Midterm - DIRECTIONS10/26/2009 7-10pmPlease read all instructions carefully. This exam consists of two parts. The first part shouldbe completed without the use of Scratch and your answers should be written on the papertitled "CS39n - Midterm - PART 1". Please note, Part 1 is significantly shorter than Part 2.Once you complete Part 1, please turn it in before continuing on to Part 2. The second partof the exam will be done on the computer. The exam and all files are available from theBSpace assignments tab. This exam is out of 60 points, but there are 66 points to earn. Wewill drop your lowest-scoring question.Name:Instructional login (eg, cs39n-ab):(6 pts) Prob 1(4 pts) Prob 2(5 pts) Prob 3(5 pts) Prob 4(5 pts) Prob 5(5 pts) Prob 6(5 pts) Prob 7(6 pts) Prob 8(5 pts) Prob 9(5 pts) Prob 10(5 pts) Prob 11(5 pts) Prob 12(5 pts) Prob 13TOTAL:CS39n - Midterm - PART 1Login: cs39n- _____1. (6 points) The dot and arrow show the current position and direction of the characterBEFORE the script is run. Draw the shape traced by each of the following scripts based uponthe start arrows drawn below. Please show the final position and direction of the characterby drawing an arrow like is shown for the start. If the arrow ends up at the same positionplease indicate that with a note that includes the final direction of the arrow. You mayassume that side-length is some positive number that allows the shapes to be drawn on thispage.a)b)c)d)e)f)2. (4 points) What is the value of the variable after the following script is run?___________CS39n - Midterm - PART 210/26/2009 7-10pmThis portion of the exam involves using Scratch and Scratch BYOB. As part of the exam youwill modify and resubmit the following Scratch files that are available on BSpace.• ShortPlay.sb• RockPaperScissors.sb• InterestRate.sbWe have provided a file on BSpace for you to type your answer for each short answerquestion. All of your short answers should go in a file called "ShortAnswers.doc".Note there may be multiple correct answers. You are welcome to use any materials on thecs39n website: inst.eecs.berkeley.edu/~cs39n/fa09/ You may watch lecture videos,however you may not use the rest of the internet!Programming:3. (5 points) We want you to make a short play. We have provided the file ShortPlay.sb inBSpace. We have also provided the file ShortPlay_example.mov in BSpace. Using Scratchyou should modify the file ShortPlay.sb to match the behavior in ShortPlay_example.mov.• When you click on the green flag the characters should go to their start positions.(These start positions are provided in the file ShortPlay.sb and should not bechanged.)• When you click on the green flag the cat should animate walking right until ittouches the bananas. (The animation of the cat should be similar to that shown inthe video, but it doesn't need to look realistic.)• When the cat touches the bananas the monkey should say "Get away from mybananas!"4. (5 points) We want you to modify the rock-paper-scissors program to make use of lists.We have provided the file RockPaperScissors.sb in BSpace. Using Scratch, please modify itto use lists. Your final program should have the same behavior in Scratch but should makeuse of lists to reduce the number of blocks necessary.5. (5 points) We want you to provide the code for a new block in Scratch BYOB to calculateinterest rate. We have provided the file InterestRate.sb in BSpace. There is currently nocode provided in the file InterestRate.sb. It should be modified to behave as describedbelow:A certain bank uses the following table as their guide in calculating interest. You shouldmake a block named "interest rate" that takes as input the amount of money and reportsthe interest rate as "3%", "2.5%", "2%" or "1%". For example if the input to the block"interest rate" was 7000, you should return "2.5%". You may assume that the your newblock "interest rate" will only be called with numbers greater than 0 and will never include a"$".Include sample test calls to the new block to show that it works.AMOUNT OF MONEY IN BANK ACCOUNT INTEREST RATEgreater than 10000 3%between 3333 and 10000 2.5%between 1000 and 3333 2%less than 1000 1%Short Answer: All of your short answers should go in a file called "ShortAnswers.doc6. (5 points) Aside from the reasons we discussed in class (simulations for training and Luisvon Ahn's games with a purpose), what is a great use of games, in terms of a benefit tosociety / individuals?7. (5 points) What is a disadvantage of duplicating a sprite many times? If you couldredesign Scratch, how would you eliminate this problem?8. (6 points) We have written two identical versions of "first". You call Version 1 by settingthe variable "sentence" and then broadcast "first". The script that receives the message"first" puts the first word of "sentence" in the variable "result". Version 2 is a block thattakes as an argument the sentence and reports the first word of that sentence.Version 1:Version 2:We want a character to say the first word in the sentence ("Go" in the examples below).Other characters may also be using first.a)This works and the character says “Go” (circle your answer)Always Sometimes NeverExplain why:b)This works and the character says “Go” (circle your answer)Always Sometimes NeverExplain why:c)This works and the character says “Go” (circle your answer)Always Sometimes NeverExplain why:9. (5 points) In a hybrid car, the electric motor can also serve as a generator to rechargethe battery, by letting the wheels turn the motor instead of the other way around. Thistakes energy away from the wheels, slowing the car. To make this happen, you push thebrake pedal. But you're not really applying the brakes -- you're charging the battery fromthe car's energy of motion. So why didn't they make a separate control for this, instead ofgiving an extra meaning to the brake pedal?10. (5 points) "I don't do anything I'm ashamed of; why should I worry about privacy?"Give at least two answers to that question.11. (5 points) What's the difference between strongly and weakly solving a game?12. (5 points) In the future, when computers have thousands of cores (simultaneousprocessing modules), which of the programming paradigms will be easiest to automaticallyparallelize and why?13. (5 points) We've talked about the positive benefits of the applications that changed theworld. Choose one of the applications that we've talked about and describe its


View Full Document

Berkeley CS 61A - Fall 2009 Paper Midterm

Download Fall 2009 Paper Midterm
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Fall 2009 Paper Midterm and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Fall 2009 Paper Midterm 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?