Codehs unit 7

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of the following statements describes a limitation of using a computer simulation to model a real-world object or system?

Computer simulations usually make some simplifying assumptions about the real-world object or system being modeled.

A scientist wants to investigate several problems. In which of the following situations is using a simulation LEAST suitable for solving a problem?

D When the solution to the problem requires real-world data inputs that are continually measured at regular intervals.

For which of the following problems is using a simulation LEAST likely to be beneficial?

Determining the longest word in a textbook

Question Shoppers at a mall were asked whether they preferred wearing gloves or mittens in cold weather. Shoppers' preferences were stored in the list voteList as strings, with the string "Gloves" representing a preference for gloves and the string "Mittens" representing a preference for mittens. The following code segment is intended to traverse the list and display the number of shoppers who chose gloves and the number of shoppers who chose mittens. numGlovesVotes ←← 0 numMittensVotes ←← 0 <MISSING CODE> { IF(vote = "Gloves") { numGlovesVotes ←← numGlovesVotes + 1 } ELSE { numMittensVotes ←← numMittensVotes + 1 } } DISPLAY(numGlovesVotes) DISPLAY(" shoppers chose gloves and") DISPLAY(numMittensVotes) DISPLAY(" shoppers chose mittens.") Which of the following should replace <MISSING CODE> so that the code segment works as intended? Responses

FOR EACH vote IN voteList

Flight simulation software, which imitates the experience of flying, is often used to train airline pilots. Which of the following is LEAST likely to be an advantage of using flight simulation software for this purpose?

Flight simulation software provides a more realistic experience for pilots than actual training flights.

Which of the following statements are true about simulation models?

I - Models often omit unnecessary features of the phenomena being modeled. II - The time it takes for a simulation to run increases as the underlying model becomes more complex.

In which of the following scenarios would a simulation be the LEAST beneficial?

In which of the following scenarios would a simulation be the LEAST beneficial?

In which of the following scenarios is using a simulation more beneficial than performing a calculation?

Investigating ways to reduce the amount of trash in the ocean Studying the effect of a genetic change in a population

A list of numbers is considered increasing if each value after the first is greater than or equal to the preceding value. The following procedure is intended to return true if numberList is increasing and return false otherwise. Assume that numberList contains at least two elements. Line 1: PROCEDURE isIncreasing(numberList) Line 2: { Line 3: count ←← 2 Line 4: REPEAT UNTIL(count > LENGTH(numberList)) Line 5: { Line 6: IF(numberList[count] < numberList[count - 1]) Line 7: { Line 8: RETURN(true) Line 9: } Line 10: count ←← count + 1 Line 11: } Line 12: RETURN(false) Line 13: } Which of the following changes is needed for the program to work as intended?

Lines 8 and 12 should be interchanged.

The following procedure is intended to return the number of times the value val appears in the list myList. The procedure does not work as intended. Line 01: PROCEDURE countNumOccurences(myList, val) Line 02: { Line 03: FOR EACH item IN myList Line 04: { Line 05: count ←← 0 Line 06: IF(item = val) Line 07: { Line 08: count ←← count + 1 Line 09: } Line 10: } Line 11: RETURN(count) Line 12: } Which of the following changes can be made so that the procedure will work as intended?

Moving the statement in line 5 so that it appears between lines 2 and 3

A population researcher is interested in predicting the number of births that will occur in a particular community. She created a computer model that uses data from the past ten years, including number of residents and the number of babies born. The model predicted that there would be 200 births last year, but the actual number of births last year was only 120. Which of the following strategies is LEAST likely to provide a more accurate prediction?

Removing as many details from the model as possible so that calculations can be performed quickly

A list of numbers has n elements, indexed from 1 to n. The following algorithm is intended to display true if the value target appears in the list more than once and to display false otherwise. The algorithm uses the variables position and count. Steps 4 and 5 are missing. Step 1:Set count to 0 and position to 1.Step 2:If the value of the element at index position is equal to target, increase the value of count by 1.Step 3:Increase the value of position by 1.Step 4:(missing step)Step 5:(missing step) Which of the following could be used to replace steps 4 and 5 so that the algorithm works as intended?

Responses Step 4Repeat steps 2 and 3 until the value of position is greater than n.Step 5If count is greater than or equal to 2, display true. Otherwise, display false.

Dominic is an industrial designer who's developing an office chair that is more comfortable for tall individuals. He hires a software engineering firm to develop a simulation that can simulate the chair used by a person working at a desk, and then come up with an estimate of the resulting comfort level. Which detail is least necessary for this simulation? Choose 1 answer:

The range of colors available for the chair's fabric

Ashlynn is an industrial engineer who is trying to design a safer parachute. She creates a computer simulation of the parachute opening at different heights and in different environmental conditions. What are advantages of running the simulation versus an actual experiment?

The simulation can be run more safely than an actual experiment. The simulation can test the parachute design in a wide range of environmental conditions that may be difficult to reliably reproduce in an experiment.

A new bank plans to make customer convenience a priority by minimizing the amount of time a customer waits in line. The bank is considering two options: a single line where the customer at the front waits for the next available teller, or separate lines for each teller. The bank decides to use a computer simulation of these two options to determine the average wait time for customers. Which of the following is NOT true about the bank's plan? Responses

The simulation will not produce usable results because actual customer data are not available.

A group of planners are using a simulation to examine whether or not a park that they are designing is going to affect foot traffic in the area. The simulation uses a model that includes input variables for the park such as the number of entrances, sidewalks, and bike trails and the square footage of open space (grassy areas). The simulation can then be run multiple times using different values for the input variables to represent different park designs. However, the simulation takes a very long time to run. The planners update the model by removing some variables they consider less important than others. Of the following, which is the most likely effect the updated model will have on the simulation?

The updated model is likely to decrease the runtime of the simulation because the time required for simulations generally depends on the complexity of the model used.

result ← 0 FOR EACH n IN list { IF (n MOD 2 = 1) { result ← result + n } } DISPLAY result

This code displays the sum of the odd numbers in list

list ← [] i ← 1 REPEAT number TIMES { IF (isComposite(i)) { APPEND(list, i) } i ← i + 1 } DISPLAY LENGTH(list)

This code displays the total number of composite numbers between 1 and number

i ← 1 FOR EACH x IN list { REMOVE(list, i) random ← RANDOM(1, LENGTH(list)) INSERT(list, random, x) i ← i + 1 }

This code shuffles the order of the numbers in the list by removing them and inserting them back in random places.

PROCEDURE Mystery (list, target) { length ← LENGTH(list) i ← 1 REPEAT length TIMES { IF (list[i] = target) { REMOVE(list, i) } ELSE { i ← i + 1 } } RETURN(list) }

This procedure returns the list without any instance of the given target

The transportation department plans to build a new high-speed train route between two cities. The transportation department wants to implement a simulation of the train before any construction begins on this project. Which of the following statements is true about the use of a simulation for this project?

Using a simulation may expose potential safety issues that can be corrected before construction begins.

A group of scientists has developed a simulation that simulates traffic in a city based on several factors. Which of the following statements is most likely something that can be learned from this simulation?

Which roads are most likely to need maintenance in the near future

Question The following code segment is intended to remove all duplicate elements in the list myList. The procedure does not work as intended. j ←← LENGTH(myList) REPEAT UNTIL(j = 1) { IF(myList[j] = myList[j - 1]) { REMOVE(myList, j) } j ←← j - 1 } For which of the following contents of myList will the procedure NOT produce the intended results?

[10, 10, 20, 20, 10, 10] [30, 50, 40, 10, 20, 40]

What is the output of the following program? function start(){ var arr = [12, 17, 65, 7, 30, 88]; var elem = arr.pop(); println(arr); println(elem); }

[12, 17, 65, 7, 30] 88

theList ←← [-2, -1, 0, 1, 2] count1 ←← 0 count2 ←← 0 FOR EACH value IN theList { IF(value > 0) { count1 ←← count1 + 1 } ELSE { count2 ←← count2 + 1 } } What are the values of count1 and count2 as a result of executing the code segment? Responses

count1 = 2, count2 = 3

A code segment is intended to transform the list utensils so that the last element of the list is moved to the beginning of the list. For example, if utensils initially contains ["fork", "spoon", "tongs", "spatula", "whisk"], it should contain ["whisk", "fork", "spoon", "tongs", "spatula"] after executing the code segment. Which of the following code segments transforms the list as intended? Responses

len ←← LENGTH(utensils) temp ←← utensils[len] REMOVE(utensils, len) INSERT(utensils, 1, temp)

A hair care products company decides to use computer simulation to develop a new anti-dandruff conditioner. The simulation helps them choose the best ingredients, the ratio to combine them at, and the optimal amount of time to leave the conditioner in the hair. When they do user testing to find out how well the conditioner works on real hair, they see mixed results. Most of the testers reported less dandruff after, but the testers with curly hair absolutely hated what it did to their curls. What was most likely true about the simulation?

t did not include a representative range of hair types.

Consider the following code segment. Assume that index1 is a number between 1 and LENGTH(theList), inclusive, and index2 is a number between 2 and LENGTH(theList) - 1, inclusive. theList ←← [9, -1, 5, 2, 4, 8] x ←← theList[index1] + theList[index2] What is the largest possible value that the variable x can have after the code segment executes?

14

Which of the following is a benefit of using a simulation instead of an experiment to make a prediction?

A simulation allows investigation of a phenomenon without the real-world limitations on time, safety, or budget. A simulation can be used to model real-world events that are impractical for experiments.

Consider the following code segment, which is intended to store ten consecutive even integers, beginning with 2, in the list evenList. Assume that evenList is initially empty. i ←← 1 REPEAT 10 TIMES { <MISSING CODE> } Which of the following can be used to replace <MISSING CODE> so that the code segment works as intended?

APPEND(evenList, 2 * i) i ←← i + 1

What is a simulation?

An abstraction of a real world phenomenon that includes some details and excludes others.

What is an array (or list)?

An ordered collection of items


Conjuntos de estudio relacionados

Chapter 41 Nutrition and Metabolism

View Set

Lección 15 (Review Quiz part 1) Prueba de vocabulario: 1- Completar; 2- Escoger; 3-Seleccionar (corrected)

View Set

Path 370 - W8: Ch.44 Brain Injury

View Set

Chapter 5 Quiz: Understanding Consumer and Business Buyer Behavior

View Set

Chapter 2 Internal Energy and Plate Tectonics

View Set

Bio 210 Test 3 Practice ch. 12, 13, 14, 15

View Set

Emergency Medicine EOR: Neurology

View Set

Chapter 8 Ga Life & Health State Laws

View Set