STUDENT NAME:______

DATE: ______SCORE: ______/ 15

CS108L Computer Science for All

FINAL EXAM – PART 2

Each student may use one 8.5x11 sheet of hand written notes (both sides).

Part 2 (15 points): 15 multiple choice questions based on the midterm exam and quizzes throughout the course. This must be taken in one continuous sitting with a time limit of 40 minutes

16. What is a computer model?

a)  An abstraction of the real world that captures the elements of the system and the behavior of the elements being modeled.

b)  Someone who serves as a subject for artists, photographers, etc.

c)  A small replica of a larger object.

d)  A device that represents something, which is used for comparison or imitation.

e)  A person who were fashionable clothing and walks down a runway.

Answer: a

17: In computer science, the two steps of decomposition are:

a) First, computer bugs lay eggs. Second, computer worms corrupt the files.

b) First, Identify parts of a problem. Second, write the steps for each part.

c) First, decompile the machine code. Second, decuple the procedures.

d) First, write the computer code. Second, run the code in behavior space.

e) First, take apart the solution. Second, take apart the algorithm.

18: 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.

19: Which of the following is NOT an example of an algorithm?

a)  A set of rules that allow you to sort objects by color.

b)  The steps that you take when doing long division by hand.

c)  A large collection of population data.

d)  A recipe for making a cake.

e)  A procedure for diagnosing a malfunction in a car engine.

20: In a NetLogo program, you have created a local variable, mylist, equal to [7 5 3 2 1]. The following command is given in your code after the list is created.

show (n-of 3 mylist)

Which of the following is a possible result displayed in the command center?

a)  [9 6 3]

b)  [7 2 1]

c)  [3]

d)  [6]

e)  [9]

21: Susan wants 4 of the patches with turtles on them to have their color set to green. Which code snippet below might make that happen?

a)  if 4 turtles-here [set pcolor green ]

b)  ask n-of 4 patches with [any? turtles-here] [set pcolor green ]

c)  ask 4 patches with [turtles-on] [set color green]

d)  repeat 4 [ask patches with [any? turtles-here] [set color green]]

e)  ask 4 patches [ set pcolor green if not any? Turtles-here set pcolor black ]

22: Achak is creating a NetLogo model with a slider that sets the variable “n” to integer values from 1 through 100. He wants the model to create a number of turtles equal to the value of the slider in a location randomly spread throughout the 2D world with an equal probability of a turtle being placed on any patch, but with no two turtles ever placed on the same patch. Which code snippet below will do what Achak needs?

a)  create-turtles n [setxy random random]

b)  create-turtles n [forward random]

c)  ask n-of n patches [ sprout 1]

d)  create-turtles n [ move-to one-of patches with [not any? turtles-here]

e)  create-turtles n turtles [ move randomly until no turtles-here]

23: Which of the following statements are NOT true about models.

a.  They capture some features of the “real world”.

b.  With computer models, programmers can sometimes capture the behavior of the parts of a real world system.

c.  Abstraction is the process of picking out features of interest from a real world situation.

d.  Building a good model requires identifying objects and behaviors in real world that contribute to larger behavior of the system.

e.  They are exactly like the “real world” to which they refer.

24: In NetLogo, which is TRUE about an agentset?

a) An agentset can have more than one copy of the same turtle.

b) An agentset can be a collection of patches with no particular order.

c) An agentset can be a mixed collection of patches and turtles.

d) An agentset can be a collection of patches arranged by patch color.

e) An agentset can have the order of its elements reversed.


25: Which of the following best describes a binary search?

a) Starting with a sorted list, divide the list in half, compare the value at the halfway point with the search item to see which half contains the search item. Repeat this process with the smaller half until the item is found.

b) Convert the list to binary numbers and use a computer algorithm to locate the item.

c) Convert the list to a sequence of ones and zeros. Then examine each sequence until you find the item you are looking for.

d) For each item in the list, check to see if it is the desired item. If yes, stop the search. If no, continue searching. Repeat this until the search item is found.

e) Convert the list to binary numbers. Then, compare each pair of adjacent numbers from left to right. If the left number in a pair is greater than the right number, then swap the numbers. Repeat this until the search item is found.

26: Which of the following is a recursive definition of factorial?

a) n! = n * (n-1) * (n-2) * ... * 1. For example: 5! = 5 * 4 * 3 * 2 * 1.

b) n! = n * (n-1)! , except when n=1, then 1! = 1. For example: 5! = 5 * 4!

c) n! = n + (n-1) + (n-1) + ... + 1. For example: 5! = 5 + 4 + 3 + 2 + 1.

d) n! = (n-1) * (n-2), except when n=1, then 1! = 1. For example: 5! = 4 * 3.

e) n! = (n-1) * (n-2), except when n=1 or n=1, then n! = 1. For example: 5! = 4 * 3.

27: In the NetLogo code below, what is the value of n displayed in the command center by the show statement?

let n 7

while (n > 1)

[ set n (n - 2)

]

show n

a)  -2

b)  1

c)  2

d)  5

e)  7

28: In a recursive program, the recursion stops when a certain test condition is met. In the recursive program below, which line contains the stopping test condition?

to spiral-recursive [stepStop]

if (stepStop < 0.01)

[ die

]

forward stepStop

right 45

spiral-recursive (stepStop * 0.9)

end

a.  to spiral-recursive [stepStop]

b.  if (stepStop < 0.01)

c.  forward stepStop

d.  spiral-recursive (stepStop * 0.9)

e.  end

29.  What is the result of the following ask turtles statement inside a go procedure?


a)  All the red turtles will die

b)  The red turtles will leave a marker behind (breed gravestones)

c)  The patch will stay brown after the red turtles have died

d)  All turtles will die.

e)  a, b and c

30. What is the result of evaluating this expression?

( true OR false ) AND true

a)  false

b)  it depends on if the statement is true or false

c)  does not compute

d)  always true.

e)  can be either true or false

CS108L_Week_16_Final_Exam_Part_2.docx Page 5 of 5