Computer Science Test prep

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

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

Determining the longest word in a textbook

A car manufacturer uses simulation software during the design process for a new car. Which of the following are reasons to use simulation software in this context? I) Using simulation software can save the company money by helping to compare designs early in the process, before prototype cars are built. II) Using simulation software can help to identify safety issues by providing data about how different mechanical components will interact in a wide variety of situations. III) The manufacturer can present simulation software to customers to demonstrate different design possibilities.

I, II, and III

A programmer has a need to round many numeric values to the nearest integer. Which of the following best explains the benefit of using a list as a data abstraction in this situation?

Keeping the numeric values in a list makes it easier to apply the same computation to every data element.

Which of the following is a benefit of using a list as a data abstraction in a program?

Lists often allow their size to be easily updated to hold as many data values as needed.

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 the number of elements in the list that have a value greater than 100. The algorithm uses the variables count and position. Steps 3 and 4 are missing. Step 1 Set count to 0 and position to 1. Step 2 If the value of the element at index position is greater than 100, increase the value of count by 1. Step 3(missing step) Step 4(missing step) Step 5Display the value of count. Which of the following could be used to replace steps 3 and 4 so that the algorithm works as intended?

Step 3 Increase the value of a position by 1. Step 4 Repeat steps 2 and 3 until the value of position is greater than n.

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?

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

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

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

A city planner is using simulation software to study crowd flow out of a large arena after an event has ended. The arena is located in an urban city. Which of the following best describes a limitation of using a simulation for this purpose?

The model used by the simulation software often omits details so that it is easier to implement.

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?

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.

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 scientist wants to investigate several problems. In which of the following situations is using a simulation LEAST suitable for solving a problem?

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

Consider the following code segment. firstList ←← ["guitar", "drums", "bass"] secondList ←← ["flute", "violin"] thirdList ←← [] thirdList ←← firstList firstList ←← secondList secondList ←← thirdList What are the contents of secondList after the code segment is executed?

["guitar", "drums", "bass"]

The algorithm below is used to simulate the results of flipping a coin 4 times. Consider the goal of determining whether the simulation resulted in an equal number of heads and tails. Step 1: Initialize the variables heads_counter and flip_counter to 0. Step 2: A variable coin_flip is randomly assigned a value of either 0 or 1. If coin_flip has the value 0, the coin flip result is heads, so heads_counter is incremented by 1. Step 3: Increment the value of flip_counter by 1. Step 4: Repeat steps 2 and 3 until flip_counter equals 4. Following execution of the algorithm, which of the following expressions indicates that the simulation resulted in an equal number of heads and tails?

heads_counter = 2

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?

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

Assume that both lists and strings are indexed starting with index 1. The list wordList has the following contents. ["abc", "def", "ghi", "jkl"] Let myWord be the element at index 3 of wordList. Let myChar be the character at index 2 of myWord. What is the value of myChar ?

"h"

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

The list wordList contains a list of 10 string values. Which of the following is a valid index for the list?

4

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

A retail company wants to determine the most popular item that was sold on the company's Web site last month.

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

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

An algorithm will be used to identify the maximum value in a list of one or more integers. Consider the two versions of the algorithm below. Algorithm I : Set the value of a variable max to − 1. Iterate through the list of integer values. If a data value is greater than the value of the variable max, set max to the data value. Algorithm II : Set the value of a variable max to the first data value. Iterate through the remaining values in the list of integers. If a data value is greater than the value of the variable max, set max to the data value. Which of the following statements best describes the behavior of the two algorithms?

Algorithm II always works correctly, but Algorithm I only works correctly when the maximum value is greater than or equal to − 1.


Conjuntos de estudio relacionados

positieve eigenschappen (adjectieven) E - F

View Set

Unit 2: Legislative Branch AP GOV test

View Set

Cellular Regulation+Breast Cancer Clicker Questions + Cancer/Breast Cancer EAQ's

View Set

BIOL 320-Aggie Honor System Rules- Definition

View Set

Elsevier adaptive quizzing- nutrition

View Set

Marketing Research Quizzes Test 2

View Set

Psych Chapter 24: Personality Disorders

View Set

Intellectual Property Rights: Copyrights

View Set