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
askturtles
[

setheading135

forward6

left90

forward4

right90

forward4

left90

forward6
]

end

  1. A “K” shape.
  2. A square shape.
  3. A rhombus (diamond) shape.
  4. A “W” shape.
  5. A “J” shape.

Hint:

Headings are set based on the “point” of a compass as used in navigation.

  1. Unless you specify the turtle location, where in the view plane does the create-turtle command of NetLogo create a turtle?

a)The turtle doesn’t appear unless it is given a location

b)The turtle appears at (0,0) also called the origin

c)The turtle appears at the bottom left corner.

d)The turtle appears at the top right corner.

e)The turtle appears at the top left corner.

  1. 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
setxy00

setheading0;;directly up on the screen

forward5

left90

forward7

forward3

right90

forward10

end

a)-5,-10

b)-10,15

c)5,10

d)-20, 10

e)10, -5

  1. 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

  1. 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.

  1. 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.

  1. In a computer program, when a sequence of instructions is executed over and over again the sequence is called ______.

a)A loop

b)Redundant

c)Very, very dead

d)Confused

e)Inefficient

  1. In the RGB color representation below which of the colors below has the same value for its R, G and B?

a)Medium Yellow

b)Sky Blue

c)Light Gray

d)Orange

e)Light Purple

  1. 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.

  1. 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.

  1. 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.

  1. Which Netlogo code segment placed within an ask turtles command block will produce an example of the “wiggle walk”?

a)rightrandom15

leftrandom15

forward1

b)right90

left90

forward1

c)rightrandom360

forward1

d) rightrandom180

forward1

e) rightrandom360

forward1

  1. In Netlogo, what is the range of values reported by: random100? Hint: random4 will never produce a 4.

a)0 through 99

b)0.0 through 100.0

c)0.0 through 99.9999

d)1 through 100

e)1.0 through 99.9999

  1. What is a uniform probability distribution?

a)Only numbers that are regularly used are used when a random number is called for.

b)Most numbers in the distribution are used all the time if a random number is called for.

c)Every number in the distribution has an equal probability of being used when a random number is called for.

d)The probability that any number is used when a random number is called for increases uniformly as the numbers increases.

e)The probability of using a number can only be determined by the user one at a time.

  1. 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

CS108L Spring 2014

Week 8: Midterm Exam – Part 2

  1. How may patches does this NetLogo 2D world have?


a) 5

b) 16

c) 25

d) 6

e) 12

  1. 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.

askpatches
[
ifelsepycor0
[ setpcolorblue

]
[ setpcolorred

]
]

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.

  1. 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.

  1. 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.

  1. 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

letmyCount0

askpatches

[

setpcolorgreen

if (myCount50)

[

setpcolorred

setmyCount (myCount + 1)

]

]

showmyCount

end

a)All of the patches.

b)None of the patches.

c)50 patches.

d)49 patches.

e)Half of the patches.

  1. 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.

  1. Which of following facts (all of which are true) acts asnegative 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 self-organization of the ants.

e)The fact that an antis one of the world’s strongest creature in relation to its size.

  1. 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.

  1. 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.

  1. 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 Netlogoprocedure is calledonce, will it hatch any turtles?

turtles-own [energy]

to go

askturtles

[

forward1

set energy (energy – 1)

if (energy < 0) [ die ]

if (pcolor = green) [ set energy (energy +15) ]

if energy >=10 [hatch1]

]

end

a)Yes all the turtles will give birth to turtles.

b)Yes, on average, a bit more than half of the turtles will give birth.

c)Yes, on average, a bit less than half of the turtles will give birth.

d)Maybe yes, maybe no. It depends on whether any turtles are on green patches.

e)No, the turtles will all die.

  1. 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.

  1. 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 variablei when the procedure is done (in the show command)?

a)49

b)50

c)over 400

d)it is stochastic

e)it depends on input


  1. 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)A square spiral that never crosses itself.

b)A square.

c)A square spiral where the larger squares cross over the smaller squares.

d)A sequence of horizontal lines.

e)A sequence of the same size squares, each rotated at a different angle.

  1. 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

  1. 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.

CS108L_Spring_2014_Mideterm_Exam_With_Answers.docx