CS108L Spring 2014 Week 8: Midterm Exam – Part 1 Note: Graph paper has been provided at the end of the test for you to use. It is not used in the grading process 1. In a Netlogo program, the procedure below is called after one turtle has been created with its pen down. The pattern drawn is best discribed as? to go ask turtles [ set heading 135 forward 6 left 90 forward 4 right 90 forward 4 left 90 forward 6 ] end a. b. c. d. e. A “K” shape. A square shape. A rhombus (diamond) shape. ***A “W” shape. A “J” shape. Hint: Headings are set based on the “point” of a compass as used in navigation. Document1 2. Unless you specify the turtle location, where in the view plane does the create-turtle command of NetLogo create a turtle? a) b) c) d) e) The turtle doesn’t appear unless it is given a location ***The turtle appears at (0,0) also called the origin The turtle appears at the bottom left corner. The turtle appears at the top right corner. The turtle appears at the top left corner. 3. After a single turtle has been created, the procedure below is called. What are the coordinates of the turtle when the procedure ends? Hint: if you do not think any answer is correct, try working your answer again—make a sketch. to move-it setxy 0 0 set heading 0 ;;directly up on the screen forward 5 left 90 forward 7 forward 3 right 90 forward 10 end 1. 2. 3. 4. 5. -5,-10 * -10,15 5,10 -20, 10 10, -5 4. A student is making a model of traffic patterns in a city. As part of this process, the student decides to include in model the number of lanes each road has, but does not include the width of each lane. This decision is part of which of the three “A”s of computional thinking? a) ***Abstraction b) Automation c) Algorithm d) Asynchronous e) Analysis Document1 5. In computer science, the three steps of decomposition are: a) First, the program crashes. Second, computer bugs lay eggs. Third, computer worms corrupt the files. b) ***First, Identify parts of a problem. Second, write the steps for each part. Third, combine the parts. c) First, decompile the machine code. Second decuple the procedures. Third, deactivate the commands. d) First, write the computer code. Second, run the code in behavior space. Third, verify the results. e) First, take apart the solution, Second, take apart the algorithm, Third, take apart the assumptions. 6. Which best describes the process of abstraction in computer modeling? a) Identifying and fixing all the places in the model that can cause the model to either “crash” or give incorrect results. b) Developing algorithms that are robust enough to handle the many special cases that arise in the model. c) Developing data structures that can efficiently manipulate the data in the model. d) ****Deciding which aspects of the real world are most important to the model’s current purpose. e) Describing, in a human readable form, how the model works so that people other than the model’s author can use and extend the model. 7. In a computer program, when a sequence of instructions is executed over and over again the sequence is called _________. a) b) c) d) e) ***A loop Redundant Very, very dead Confused Inefficient 8. In the RGB color representation below which of the colors below has the same value for its R, G and B? a. b. c. d. e. Medium Yellow Sky Blue *** Light Gray Orange Light Purple Document1 9. What is a local variable? a) A variable that can only be used by one agent. b)*** A variable that can only be used in the procedure or command block where it is declared. c) A variable that contain information about agents in the local environment. d) A variable that is of interest to locals. e) A variable that can only be used by local agents. 10. What three rules did Graig Reynolds use to provide evedance that it might not be nessasarry to have a “leader bird” to produce the flocking behavior observed in many species of birds? a) Keep angle to sun constant. Go in the same direction of neighbors. Avoid predators. b) Avoid predators. Travel south in late autumn. Find food. c) Don’t fly outside the flock. Avoid predators. Fly forward. d) ***Go in the same direction as your neighbors. Don’t get too near to or too far from your neighbors. Avoid predators. e) Travel with the strongest winds in both late autumn and early spring. Find Food, Avoid predators. 11. What factors allow an agent-based model to produce different results upon different runs with the same input parameters? a) The use of agent based variables. b) ***The use of random numbers in the model. c) The use of global variables. d) The use of input parameters. e) The use of patches in the model. Document1 12. Which Netlogo code segment placed within an ask turtles command block will produce an example of the “wiggle walk”? ***a) right random 15 left random 15 forward 1 b) right 90 left 90 forward 1 c) right random 360 forward 1 d) right random 180 forward 1 e) right random 360 forward 1 13. In Netlogo, what is the range of values reported by: random 100? Hint: random 4 will never produce a 4. a) b) c) d) e) ***0 through 99 0.0 through 100.0 0.0 through 99.9999 1 through 100 1.0 through 99.9999 14. What is a uniform probability distribution? a) b) c) d) e) Only numbers that are regularly used are used when a random number is called for. Most numbers in the distribution are used all the time if a random number is called for. ***Every number in the distribution has an equal probability of being used when a random number is called for. The probability that any number is used when a random number is called for increases uniformly as the numbers increases. The probability of using a number can only be determined by the user one at a time. Document1 15. The Netlogo code segment below will display which three values in the command center? Hint: It is easier to make a compound OR statement true than a compound AND statement. let r 200 let g 10 let b 155 show (r > g) and (r > b) show (g < b) or (g > r) show (g < b) and (g > r) a) false, true, false b) ***true, true, false c) true, false, false d) true, false, true e) false, true, true Document1 CS108L Spring 2014 Week 8: Midterm Exam – Part 2 16. How may patches does this NetLogo 2D world have? a) 5 b) 16 c) ***25 d) 6 e) 12 Document1 17. In the default Netlogo 2D world view, which is the most accurate decription of the result of the following code? Hint: pycor is the NetLogo way of refering to the y dimension of an ordinary Cartesian (x-y) coordinate graph. The middle patch has coordinates pxcor = 0 and pycor = 0, the one below the middle patch has coordinates pxcor = 0 and pycor = -1. ask patches [ ifelse pycor < 0 [ set pcolor blue ] [ set pcolor red ] ] a) The patches on the left half of the world are blue and the patches on the right half of the world are red. b) ***The patches on the bottom half of the world are blue and patches on the top half of the world are red. c) The patches on the right half of the world are blue and the patches on the left half of the world are red. d) All the patches turn blue. Then all the patches turn red. e) All the patches turn blue since pycor must always be positive. 18. In a computer program, what is a variable? a) A variable is part of the program that changes randomly each time the program is run. b) *** A variable is a memory storage location referenced by a name and containing a value that can be used and changed. c) A variable is the part of the code that changes itself. d) A variable is a change in the programming language used when creating a program. e) A variable is a memory storage location that changes each time the programmer accesses it. Document1 19. In a model where fish are born, reproduce and die, you might want to keep track of the total number of fish that were ever born. This would require use of a global variable since individuals come and go. How would you define a global variable? a) A variable that can hold many different values at the same time. b) A variable that can only be accessed from outside the program. c) ***A variable that is shared by and can be accessed by all parts of a program. d) A variable used in models that effect the whole world such as climate models, human population models and models of the ocean currents. e) A variable that can only be used in the procedure in which it was declared. 20. In a Netlogo program with max-pxcor = 6, max-pycor = 6 and the location of the origin at the center, how many patches are colored green after the setup procedure below is called? to setup clear-all let myCount 0 ask patches [ set pcolor green if (myCount < 50) [ set pcolor red set myCount (myCount + 1) ] ] show myCount end a) b) c) d) e) All of the patches. None of the patches. ***50 patches. 49 patches. Half of the patches. Document1 21. Assume that you have a stochastic model that is a good abstraction of a real-world situation. Which of the following is the least important (or unimportant) element when running a stochastic computer model to make generalizations and conclusions about the model’s behavior? a) Sweeping input parameters. b) Repetitions at each set of input parameters. c) Recording the output and recording which set in input parameters were used in the run that generated that output. d) ***Randomly selecting input parameters until the required output is obtained. e) Using some kind of statisical tools to understand, visualize or average results. 22. Which of following facts (all of which are true) acts as negative feedback for a population of ants? a) ***The fact that each ant needs food to live and the supply of food is finite. b) The fact that almost all species of ants sleep quite frequently. c) The fact that among the worker ants of a colony, there is a division of labor into tasks such as colony upkeep, foraging and nest defense. d) The fact that there is no “head of the colony” telling the ants what to do. The subsistence of the colony is instead supported by a self-regulatory mechanism that provides resilience and robustness, through the local selforganization of the ants. e) The fact that an ant is one of the world’s strongest creature in relation to its size. 23. In Blown-to-Bits, Lewis, Ledeen and Abelson assert that we leave digital fingerprints when we use our computers and access the Internet because_____ a) ***Accessing the Internet means downloading information to the computer, some part of the system must know where we are to do that. This leaves a trail. b) People often choose to fill out forms on the Internet and enter personal information. c) People often choose to use school or company owned computers to access the Internet and these computers are often monitored. d) People sometimes use computers with viruses or other malware which can track all the user’s accesses. e) Even in a dry climate like New Mexico, people always have some oils on their fingers – this is especially true when eating at the keyboard. Document1 24. What is the main difference between a deterministic simulation and a stochastic simulation? a) A deterministic simulation is used to determine whether the model is correct by checking it against a known result. A stochastic simulation is used when the expected results are not known. b) A deterministic simulation involves numbers and rigorous mathematics whereas a stochastic simulation does not. c) ***A deterministic simulation does not involve randomness whereas a stochastic simulation does involve randomness. d) A deterministic simulation is more accurate whereas a stochastic simulation is more intuitive. e) A deterministic simulation is used to simulate real world events and problems whereas and a stochastic simulation is used in games. 25. Assume that before the Netlogo program below is called, 100 turtles have been created each with its energy value equal to 10. Then, when the following Netlogo procedure is called once, will it hatch any turtles? turtles-own [energy] to go ask turtles [ forward 1 set energy (energy – 1) if (energy < 0) [ die ] if (pcolor = green) [ set energy (energy + 15) ] if energy >= 10 [hatch 1] ] end a) b) c) d) Yes all the turtles will give birth to turtles. Yes, on average, a bit more than half of the turtles will give birth. Yes, on average, a bit less than half of the turtles will give birth. ***Maybe yes, maybe no. It depends on whether any turtles are on green patches. e) No, the turtles will all die. Document1 26. What is a Radio Frequency Identification tag (RFID) a) An electronic identification system that can only be used for official government purposes on important items. b) A sequence of 4 letters used to identify both public and private radio stations. c) ***Something containing electronically stored information that can be both powered from a few feet away and read from a few feet away. d) Silicon chips embedded in plastic that require small batteries or some other internal power source to transmit their ID number. e) A radio that has a tag that can be used to identify the station that is playing. 27. You decide to create a fifty turtles in a world that has over 400 patches. You use the code below. What is the value of the local variable i when the procedure is done (in the show command)? a) b) c) d) e) 49 ***50 over 400 it is stochastic it depends on input Document1 28. The Netlogo procedure below is executed with 2D world settings of max-pxcor = 16, max-pycor = 16 and the location of the origin at the center. What pattern will be drawn by the turtle: a) b) c) d) e) A square spiral that never crosses itself. A square. A square spiral where the larger squares cross over the smaller squares. ***A sequence of horizontal lines. A sequence of the same size squares, each rotated at a different angle. Document1 29. When the Netlogo procedure below is called, the lines drawn by the turtle will: a) ***Never cross b) Cross once c) Cross twice d) Cross four times e) Cross five times 30. Within the field of complex adaptive systems, the structure of termite mounds is a classic example of _______? a) Termites and other creatures being much smarter than we usually recognize. b) How very little we a humans really understand about the natural world around us. c) How both deterministic and non-deterministic processes can merge in a positive feedback loop. d) ***Emergent patterns that develop from simple interactions of agents. e) How both positive and negative feedback loops contribute to structural solutions in crowd dynamics. Document1 Document1