wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Ap computer science

Total questions: 142

Worksheet time: 7hrs 4mins

Name
Class
Date
1.

Collaboration can provide which of the following?

a)

Several points of failure

b)

clean data

c)

Duplication of effort

d)

Better products resulting from different perspectives

2.

What is a benefit of using a software development design process?

a)

By following the process, the code will work the first time.

b)

Using the process, the code will be efficient regardless of a programmer’s experience.

c)

The code will be developed in 50% less time using a development/design process.

d)

The process is iterative, resulting in a better program.

3.

What is a crucial step in an iterative development process?

a)

Feedback

b)

preparing prototypes

c)

meeting deadlines

d)

meeting budget constraints

4.

What is a benefit of understanding a problem before coding?

a)

A better-designed program is created to handle all the needed functionality.

b)

Less testing is required.

c)

Little or no documentation is then needed.

d)

Users will not need training to use the program.

5.

Which of the following is not a common step in many software development processes?

a)

Designing

b)

Investigating

c)

Identifying patterns

d)

Testing

6.

What do using surveys, interviews, and observations identify?

a)

Device specifications

b)

Program errors

c)

User requirements

d)

Valid program input

7.

Which phase in the development process determines how to meet the application requirements?

a)

Analysis

b)

Design

c)

Programming

d)

Testing

8.

How do event-driven programs progress?

a)

They run in a linear fashion from start to end

b)

The code executes sequentially

c)

The code executes when an action occurs that it is programmed to recognize

d)

The code runs iteratively

9.

Why is documentation important?

a)

To explain a program’s purpose and functionality

b)

To make it easier to understand and modify the code later

c)

To be useful for training people on how to use the program

d)

All of the above

10.

Why should boundary values be tested?

a)

Testing boundary value is not necessary.

b)

To ensure they are identified as errors

c)

To ensure warning messages are sent about the boundaries.

d)

To ensure the program does not include too few or too many elements

11.

What is one way to debug a program?

a)

Add temporary print messages to determine program values

b)

Test with different data values each time

c)

Document the error in the user guide and online help text

d)

Override the error with the correct value.

12.

Which development process breaks the requirements down into small modules and adds the code, once working, to the projects as a whole?

a)

Additive

b)

Incremental

c)

Iterative

d)

Spiral

13.

What is one way to ensure testing is thorough?

a)

Create expected results prior to testing

b)

Create a diagram of the program’s processing

c)

Execute the code to ensure it runs.

d)

Add temporary DISPLAY statements to see intermediate results in the program.

14.

What type of error breaks the rules of the programming language, like a grammatical error?

a)

Logic error

b)

Overflow error

c)

Runtime error

d)

Syntax error

15.

If your program executes without errors, but the results are incorrect, what type of error do you likely have?

a)

Logic error

b)

Round off error

c)

Runtime error

d)

Syntax error

16.

Which method of finding errors is most useful to identify logic errors?

a)

Creating new test cases

b)

Hand tracing

c)

Rerunning the program with different inputs to see the impact on outputs

d)

Running a simulation

17.

Attempting to access an invalid index in a list results in what type of error?

a)

Logic error

b)

Overflow error

c)

Runtime error

d)

Syntax error

18.

What is an example of event-driven programming?

a)

Prompting a user to type in a response

b)

Using constraints for data values in place of variables

c)

A mobile device that orients to a new position

d)

A microphone transmitting audio data to a program.

19.

A company that develops educational software wants to assemble a collaborative team of developers from a variety of professional and cultural backgrounds. Which of the following is NOT considered a benefit of assembling such a team?

a)

Collaboration that includes diverse backgrounds and perspectives can eliminate the need for software testing.

b)

Collaboration that includes diverse backgrounds and perspectives can help the team anticipate the needs of a variety of software users.

c)

Collaboration that includes diverse backgrounds and perspectives can help the team avoid bias.

d)

Collaboration that includes diverse backgrounds and perspectives can reflect the strengths of the individual team members.

20.

Three students in different locations are collaborating on the development of an application. Which of the following strategies is LEAST likely to facilitate collaboration among the students?

a)

Having all three students participate in frequent video chat sessions to discuss ideas about the project and to provide feedback on work done so far

b)

Having all three students use an online shared folder to contribute and discuss components to be considered for use in the application

c)

Having all three students write code independently and then having one student combine the code into a program

d)

Having all three students work in a shared document that each can edit to provide comments on the work in progress

21.

A company that develops mobile applications wants to involve users in the software development process. Which of the following best explains the benefit in having users participate?

a)

Users can identify and correct errors they encounter when using released versions of the software.

b)

Users can review the algorithms used in the software to help improve their efficiency.

c)

Users can provide documentation for program code at the end of the software development process.

d)

Users can provide feedback that can be used to incorporate a variety of perspectives into the software.

22.

Which of the following best describes the behavior of the code segment?

a)

The code segment displays the value of 2(5×3) by initializing result to 2 and then multiplying result by 3 a total of five times.

b)

The code segment displays the value of 2(5×3) by initializing result to 2 and then multiplying result by 5 a total of three times.

c)

The code segment displays the value of 2(5^3) by initializing result to 2 and then multiplying result by 3 a total of five times.

d)

The code segment displays the value of 2(5^3) by initializing result to 2 and then multiplying result by 5 a total of three times.

23.

In the following procedure, assume that the parameter x is an integer.

Which of the following best describes the behavior of the procedure?

a)

It displays nothing if x is negative and displays true otherwise.

b)

It displays nothing if x is negative and displays false otherwise.

c)

It displays true if x is negative and displays nothing otherwise.

d)

It displays true if x is negative and displays false otherwise.

24.

DineOutHelper is a mobile application that people can use to select a restaurant for a group meal. Each user creates a profile with a unique username and a list of food allergies or dietary restrictions. Each user can then build a contact list of other users of the app.

A user who is organizing a meal with a group selects all the members of the group from the user’s contact list. The application then recommends one or more nearby restaurants based on whether the restaurant can accommodate all of the group members’ allergies and dietary restrictions.

Suppose that Alejandra is using DineOutHelper to organize a meal with Brandon and Cynthia.

Which of the following data are needed for DineOutHelper to recommend a restaurant for the group?

l. Each group member’s list of food allergies or dietary restrictions

ll. Alejandra’s geographic location

lll. The usernames of the people on Brandon and Cynthia’s contact lists

a)

I and II only

b)

I and III only

c)

II and III only

d)

I, II, and III

25.

DineOutHelper is a mobile application that people can use to select a restaurant for a group meal. Each user creates a profile with a unique username and a list of food allergies or dietary restrictions. Each user can then build a contact list of other users of the app.

A user who is organizing a meal with a group selects all the members of the group from the user’s contact list. The application then recommends one or more nearby restaurants based on whether the restaurant can accommodate all of the group members’ allergies and dietary restrictions.

Suppose that Alejandra is using DineOutHelper to organize a meal with Brandon and Cynthia.

Which of the following data is not provided by Alejandra but is necessary for DineOutHelper to recommend a restaurant for the group?

l. Brandon’s contact list

ll. Information about which restaurants Brandon and Cynthia have visited in the past

lll. Information about which food allergies and dietary restrictions can be accommodated at different restaurants near Alejandra

a)

ll only

b)

lll only

c)

II and III only

d)

I, II, and III

26.

A student wrote the following code segment, which displays true if the list myList contains any duplicate values and displays false otherwise.

The code segment compares pairs of list elements, setting containsDuplicates to true if any two elements are found to be equal in value. Which of the following best describes the behavior of how pairs of elements are compared?

a)

The code segment iterates through myList, comparing each element to all other elements in the list.

b)

The code segment iterates through myList, comparing each element to all subsequent elements in the list.

c)

The code segment iterates through myList, comparing each element to the element that immediately follows it in the list.

d)

The code segment iterates through myList, comparing each element to the element that immediately precedes it in the list.

27.

A student is creating an application that allows customers to order food for delivery from a local restaurant. Which of the following is LEAST likely to be an input provided by a customer using the application?

a)

The address where the order should be delivered

b)

The cost of a food item currently available for order

c)

The credit card or payment information for the purchaser

d)

The name of a food item to be included in the delivery

28.

In the following procedure, the parameter max is a positive integer.

PROCEDURE printNums(max)

{

count

← 1

REPEAT UNTIL(count > max)

{

DISPLAY(count)

count

← count + 2

}

}

Which of the following is the most appropriate documentation to appear with the printNums procedure?

a)

Prints all positive even integers that are less than or equal to max.

b)

Prints all positive odd integers that are less than or equal to max.

c)

Prints all positive even integers that are greater than max.

d)

Prints all positive odd integers that are greater than max.

29.

In the following procedure, the parameters x and y are integers.

Which of the following is the most appropriate documentation to appear with the calculate procedure?

a)

Displays the value of x + (y / x).

The value of the parameter x must not be 0.

b)

Displays the value of x + (y / x).

The value of the parameter y must not be 0.

c)

Displays the value of (x + y) / x.

The value of the parameter x must not be 0.

d)

Displays the value of (x + y) / x.

The sum of the parameters x and y must not be 0.

30.

In the following procedure, the parameter numList is a list of numbers and the parameters j and k are integers.

PROCEDURE swapListElements(numList, j, k)

{

newList

← numList

newList[j]

← numList[k]

newList[k]

← numList[j]

RETURN(newList)

}

Which of the following is the most appropriate documentation to appear with the swapListElements procedure?

a)

Returns a copy of numList with the elements at indices j and k interchanged.

The value of j must be between 0 and the value of k, inclusive.

b)

Returns a copy of numList with the elements at indices j and k interchanged.

The values of j and k must both be between 1 and LENGTH(numList), inclusive

c)

Interchanges the values of the parameters j and k.

The value of j must be between 0 and the value of k, inclusive.

d)

Interchanges the values of the parameters j and k.

The values of j and k must both be between 1 and LENGTH(numList), inclusive.

31.

In the following code segment, score and penalty are initially positive integers. The code segment is intended to reduce the value of score by penalty. However, if doing so would cause score to be negative, score should be assigned the value 0.

For example, if score is 20 and penalty is 5, the code segment should set score to 15.

If score is 20 and penalty is 30, score should be set to 0.

The code segment does not work as intended.

Line 1: IF(score - penalty < 0)

Line 2: {

Line 3: score

← score - penalty

Line 4: }

Line 5: ELSE

Line 6: {

Line 7: score

← 0

Line 8: }

Which of the following changes can be made so that the code segment works as intended?

a)

Changing line 1 to IF(score < 0)

b)

Changing line 1 to IF(score + penalty < 0)

c)

Changing line 7 to score ← score + penalty

d)

Interchanging lines 3 and 7

32.

The following procedure is intended to return true if the list of numbers myList contains only positive numbers and is intended to return false otherwise. The procedure does not work as intended.

PROCEDURE allPositive(myList)

{

index ← 1

len ← LENGTH(myList)

REPEAT len TIMES

{

IF(myList[index] > 0)

{

RETURN(true)

}

index ← index + 1

}

RETURN(false)

For which of the following contents of myList does the procedure NOT return the intended result?

a)

[-3, -2, -1]

b)

[-2, -1, 0]

c)

[-1, 0, 1]

d)

[1, 2, 3]

33.

A homework assignment consists of 10 questions. The assignment is graded as follows.

Number of Correct Answers

Grade

9–10

check plus

7–8

check

Under 7

check minus

Let numCorrect represent the number of correct answers for a particular student. The following code segment is intended to display the appropriate grade based on numCorrect. The code segment does not work as intended in all cases.

For which of the following values of numCorrect does the code segment NOT display the intended grade?

a)

9

b)

8

c)

7

d)

6

34.

Which data compression technique provides the most compression?

a)

Lossy

b)

Lossless

c)

Filtering

d)

Classification

35.

Which of the following best describes abstraction?

a)

Adding complexity so the concept can apply to more uses

b)

Simplifying complexity to make the concept more general.

c)

Combining procedures to make a new one

d)

A set of instructions to do a task

36.

Why is cleaning data important?

a)

It ensures incomplete data does not hide or skew results

b)

It removes bad data

c)

It repairs incomplete data

d)

All of the above

37.

Why is analyzing data with computers important?

a)

To identify patterns that humans cannot see

b)

To increase the viability of server farms

c)

To verify existing solutions to problems

d)

To test due diligence

38.

What is the number system used by computers?

a)

Base 10 (decimal)

b)

Base 8 (octal)

c)

Base 2 (binary)

d)

Base 16 (hexadecimal)

39.

A certain programming language uses 4-bit binary sequences to represent nonnegative integers. For example, the binary sequence 0101 represents the corresponding decimal value 5. Using this programming language, a programmer attempts to add the decimal values 14 and 15 and assign the sum to the variable total. Which of the following best describes the result of this operation?

a)

The correct sum of 29 will be assigned to the variable total.

b)

An overflow error will occur because 4 bits is not large enough to represent either of the values 14 or 15.

c)

An overflow error will occur because 4 bits is not large enough to represent 29, the sum of 14 and 15.

d)

A round-off error will occur because the decimal values 14 and 15 are represented as approximations due to the fixed number of bits used to represent numbers.

40.

A video game character can face toward one of four directions: north, south, east, and west. Each direction is stored in memory as a sequence of four bits. A new version of the game is created in which the character can face toward one of eight directions, adding northwest, northeast, southwest, and southeast to the original four possibilities. Which of the following statements is true about how the eight directions must be stored in memory?

a)

Four bits are not enough to store the eight directions. Five bits are needed for the new version of the game.

b)

Four bits are not enough to store the eight directions. Eight bits are needed for the new version of the game.

c)

Four bits are not enough to store the eight directions. Sixteen bits are needed for the new version of the game.

d)

Four bits are enough to store the eight directions.

41.

Which of the following are true statements about the data that can be represented using binary sequences?

l. Binary sequences can be used to represent strings of characters.

ll. Binary sequences can be used to represent colors.

lll. Binary sequences can be used to represent audio recordings.

a)

I only

b)

I and II only

c)

II and III only

d)

I, II, and III

42.

Consider the 4-bit binary numbers 0011, 0110, and 1111. Which of the following decimal values is NOT equal to one of these binary numbers?

a)

3

b)

6

c)

9

d)

15

43.

The position of a runner in a race is a type of analog data. The runner’s position is tracked using sensors. Which of the following best describes how the position of the runner is represented digitally?

a)

The position of the runner is determined by calculating the time difference between the start and the end of the race and making an estimation based on the runner’s average speed.

b)

The position of the runner is measured and rounded to either 0 or 1 depending on whether the runner is closer to the starting line or closer to the finish line.

c)

The position of the runner is predicted using a model based on performance data captured from previous races.

d)

The position of the runner is sampled at regular intervals to approximate the real-word position, and a sequence of bits is used to represent each sample.

44.

Consider the following numeric values.

Binary 1011

Binary 1101

Decimal 5

Decimal 12

Which of the following lists the values in order from least to greatest?

a)

Decimal 5, binary 1011, decimal 12, binary 1101

b)

Decimal 5, decimal 12, binary 1011, binary 1101

c)

Decimal 5, binary 1011, binary 1101, decimal 12

d)

Binary 1011, binary 1101, decimal 5, decimal 12

45.

Which of the following is an advantage of a lossless compression algorithm over a lossy compression algorithm?

a)

A lossless compression algorithm can guarantee that compressed information is kept secure, while a lossy compression algorithm cannot.

b)

A lossless compression algorithm can guarantee reconstruction of original data, while a lossy compression algorithm cannot.

c)

A lossless compression algorithm typically allows for faster transmission speeds than does a lossy compression algorithm.

d)

A lossless compression algorithm typically provides a greater reduction in the number of bits stored or transmitted than does a lossy compression algorithm.

46.

A user wants to save a data file on an online storage site. The user wants to reduce the size of the file, if possible, and wants to be able to completely restore the file to its original version. Which of the following actions best supports the user’s needs?

a)

Compressing the file using a lossless compression algorithm before uploading it

b)

Compressing the file using a lossy compression algorithm before uploading it

c)

Compressing the file using both lossy and lossless compression algorithms before uploading it

d)

Uploading the original file without using any compression algorithm

47.

A programmer is developing software for a social media platform. The programmer is planning to use compression when users send attachments to other users. Which of the following is a true statement about the use of compression?

a)

Lossless compression of video files will generally save more space than lossy compression of video files.

b)

Lossless compression of an image file will generally result in a file that is equal in size to the original file.

c)

Lossy compression of an image file generally provides a greater reduction in transmission time than lossless compression does.

d)

Sound clips compressed with lossy compression for storage on the platform can be restored to their original quality when they are played.

48.

A researcher is analyzing data about students in a school district to determine whether there is a relationship between grade point average and number of absences. The researcher plans on compiling data from several sources to create a record for each student.

The researcher has access to a database with the following information about each student.

Last name

First name

Grade level (9, 10, 11, or 12)

Grade point average (on a 0.0 to 4.0 scale)

The researcher also has access to another database with the following information about each student.

First name

Last name

Number of absences from school

Number of late arrivals to school

Upon compiling the data, the researcher identifies a problem due to the fact that neither data source uses a unique ID number for each student. Which of the following best describes the problem caused by the lack of unique ID numbers?

a)

Students who have the same name may be confused with each other.

b)

Students who have the same grade point average may be confused with each other.

c)

Students who have the same grade level may be confused with each other.

d)

Students who have the same number of absences may be confused with each other.

49.

A team of researchers wants to create a program to analyze the amount of pollution reported in roughly 3,000 counties across the United States. The program is intended to combine county data sets and then process the data. Which of the following is most likely to be a challenge in creating the program?

a)

A computer program cannot combine data from different files.

b)

Different counties may organize data in different ways.

c)

The number of counties is too large for the program to process.

d)

The total number of rows of data is too large for the program to process.

50.

A student is creating a Web site that is intended to display information about a city based on a city name that a user enters in a text field. Which of the following are likely to be challenges associated with processing city names that users might provide as input?

Select two answers.

a)

Users might attempt to use the Web site to search for multiple cities.

b)

Users might enter abbreviations for the names of cities.

c)

Users might misspell the name of the city.

d)

Users might be slow at typing a city name in the text field.

51.

A database of information about shows at a concert venue contains the following information.

Name of artist performing at the show

Date of show

Total dollar amount of all tickets sold

Which of the following additional pieces of information would be most useful in determining the artist with the greatest attendance during a particular month?

a)

Average ticket price

b)

Length of the show in minutes

c)

Start time of the show

d)

Total dollar amount of food and drinks sold during the show

52.

A camera mounted on the dashboard of a car captures an image of the view from the driver’s seat every second. Each image is stored as data. Along with each image, the camera also captures and stores the car’s speed, the date and time, and the car’s GPS location as metadata. Which of the following can best be determined using only the data and none of the metadata?

a)

The average number of hours per day that the car is in use

b)

The car’s average speed on a particular day

c)

The distance the car traveled on a particular day

d)

The number of bicycles the car passed on a particular day

53.

A teacher sends students an anonymous survey in order to learn more about the students’ work habits. The survey contains the following questions.

On average, how long does homework take you each night (in minutes) ?

On average, how long do you study for each test (in minutes) ?

Do you enjoy the subject material of this class (yes or no) ?

Which of the following questions about the students who responded to the survey can the teacher answer by analyzing the survey results?

l. Do students who enjoy the subject material tend to spend more time on homework each night than the other students do?

ll. Do students who spend more time on homework each night tend to spend less time studying for tests than the other students do?

lll. Do students who spend more time studying for tests tend to earn higher grades in the class than the other students do?

a)

l only

b)

lll only

c)

l and ll

d)

1 and lll

54.

A large spreadsheet contains the following information about the books at a bookstore. A sample portion of the spreadsheet is shown below.

A

Book Title

B

Author

C

Genre

D

Number of

Copies in Stock

E

Cost

(in dollars)

1

Little Women

Louisa May Alcott

Fiction

3

13.95

2

The Secret Adversary

Agatha Christie

Mystery

2

12.95

3

A Study in Scarlet

Arthur Conan Doyle

Mystery

0

8.99

4

The Hound of the Baskervilles

Arthur Conan Doyle

Mystery

1

8.95

5

Les Misérables

Victor Hugo

Fiction

1

12.99

6

Frankenstein

Mary Shelley

Horror

2

11.95

An employee wants to count the number of books that meet all of the following criteria.

Is a mystery book

Costs less than $10.00

Has at least one copy in stock

For a given row in the spreadsheet, suppose genre contains the genre as a string, num contains the number of copies in stock as a number, and cost contains the cost as a number. Which of the following expressions will evaluate to true if the book should be counted and evaluate to false otherwise?

a)

(genre = "mystery") AND ((1 ≤ num) AND (cost < 10.00))

b)

(genre = "mystery") AND ((1 < num) AND (cost < 10.00))

c)

(genre = "mystery") OR ((1 ≤ num) OR (cost < 10.00))

d)

(genre = "mystery") OR ((1 < num) OR (cost < 10.00))

55.

The owner of a clothing store records the following information for each transaction made at the store during a 7-day period.

The date of the transaction

The method of payment used in the transaction

The number of items purchased in the transaction

The total amount of the transaction, in dollars

Customers can pay for purchases using cash, check, a debit card, or a credit card.

Using only the data collected during the 7-day period, which of the following statements is true?

a)

The average amount spent per day during the 7-day period can be determined by sorting the data by the total transaction amount, then adding the 7 greatest amounts, and then dividing the sum by 7.

b)

The method of payment that was used in the greatest number of transactions during the 7-day period can be determined by sorting the data by the method of payment, then adding the number of items purchased for each type of payment method, and then finding the maximum sum.

c)

The most expensive item purchased on a given date can be determined by searching the data for all items purchased on the given date and then sorting the matching items by item price.

d)

The total number of items purchased on a given date can be determined by searching the data for all transactions that occurred on the given date and then adding the number of items purchased for each matching transaction.

56.

A company uses the following data files.

File Name

Description

Contents

Customers

A list of customers

Customer ID

Customer address

Customer e-mail address

Customer phone number

Products

A list of products available for purchase from the company

Product ID

Product name

Type of battery used by the product, if any

Purchases

A list of customer purchases

Product ID

Product serial number

Customer ID

A new rechargeable battery pack is available for products that use AA batteries. Which of the following best explains how the data files in the table can be used to send a targeted e-mail to only those customers who have purchased products that use AA batteries to let them know about the new accessory?

a)

Use the customer IDs in the purchases file to search the customers file to generate a list of e-mail addresses

b)

Use the product IDs in the purchases file to search the products file to generate a list of product names that use AA batteries

c)

Use the customers file to generate a list of customer IDs, then use the list of customer IDs to search the products file to generate a list of product names that use AA batteries

d)

Use the products file to generate a list of product IDs that use AA batteries, then use the list of product IDs to search the purchases file to generate a list of customer IDs, then use the list of customer IDs to search the customers file to generate a list of e-mail addresses

57.

A student is developing an algorithm to determine the name of the photographer who took the oldest photograph in the collection. Photographs whose photographer or year are unknown are to be ignored.

Once the algorithm is complete, the desired entry will appear in the first row of the spreadsheet. If there are multiple entries that meet the desired criteria, then any of them can appear in the first row.

The student has the following actions available.

Action

Explanation

Filter by photographer

Removes entries whose photographer is "(unknown)"

Filter by year

Removes entries whose year is -1

Sort by subject

Sorts the rows in the spreadsheet on column B alphabetically from A to Z

Sort by year

Sorts the rows in the spreadsheet on column C from least to greatest

Assume that applying either of the filters will not change the relative order of the rows remaining in the spreadsheet.

Which of the following sequences of steps can be used to identify the desired entry?

Select two answers.

a)

Filter by photographer, then filter by year, then sort by subject

b)

Filter by photographer, then filter by year, then sort by year

c)

Sort by subject, then sort by year, then filter by photographer

d)

Sort by year, then filter by year, then filter by photographer

58.

For a given row in the spreadsheet, suppose genre contains the genre as a string and day contains the day as a string. Which of the following expressions will evaluate to true if the show should be counted and evaluates to false otherwise?

a)

(genre = "talk") AND ((day = "Saturday") AND (day = "Sunday"))

b)

(genre = "talk") AND ((day = "Saturday") OR (day = "Sunday"))

c)

(genre = "talk") OR ((day = "Saturday") AND (day = "Sunday"))

d)

(genre = "talk") OR ((day = "Saturday") OR (day = "Sunday"))

59.

Classification: mammal

Skin type: fur

Thermoregulation: warm-blooded

Lifestyle: pack

Average life span: 10–12 years

Top speed: 75 kilometers/hour

The preserve has two databases of information available to use for the exhibit. The first database contains information for each animal’s name, classification, skin type, and thermoregulation. The second database contains information for each animal’s name, lifestyle, average life span, and top speed.

Which of the following explains how the two databases can be used to develop the interactive exhibit?

a)

Only the first database is needed. It can be searched by animal name to find all the information to be displayed.

b)

Only the second database is needed. It can be searched by animal name to find all the information to be displayed.

c)

Both databases are needed. Each database can be searched by animal name to find all information to be displayed.

d)

The two databases are not sufficient to display all the necessary information because the intended display information does not include the animal name.

60.

The variable age is to be used to represent a person’s age, in years. Which of the following is the most appropriate data type for age ?

a)

Boolean

b)

number

c)

string

d)

list

61.

The variable isOpen is to be used to indicate whether or not a store is currently open. Which of the following is the most appropriate data type for isOpen ?

a)

Boolean

b)

number

c)

String

d)

list

62.

A teacher is writing a code segment that will use variables to represent a student’s name and whether or not the student is currently absent. Which of the following variables are most appropriate for the code segment?

a)

A string variable named s and a Boolean variable named a

b)

A string variable named s and a numeric variable named n

c)

A string variable named studentName and a Boolean variable named isAbsent

d)

A string variable named studentName and a numeric variable named numAbsences

63.

What is the value of r as a result of executing the code segment?

a)

10

b)

20

c)

30

d)

40

64.

What are the values of first and second as a result of executing the code segment?

a)

The value of first is true, and the value of second is true.

b)

The value of first is true, and the value of second is false.

c)

The value of first is false, and the value of second is true.

d)

The value of first is false, and the value of second is false.

65.

Consider the following code segment.

X ← 25

y ← 50

z ← 75

x ← y

y ← z

z ← x

Which of the variables have the value 50 after executing the code segment?

a)

X only

b)

y only

c)

x and z only

d)

X, Y, Z

66.

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

a)

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

b)

Lists convert all elements to strings so that they can be inspected character-by-character.

c)

Lists prevent duplicate data values from appearing in the list.

d)

Lists are used to store all input data so that there is a running record of all user input.

67.

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?

a)

Keeping the numeric values in a list makes it easier to round a number to the nearest integer.

b)

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

c)

Keeping the numeric values in a list makes it easier to prevent a program from unintentionally changing the value of a variable.

d)

Keeping the numeric values in a list makes it easier to prevent a program from attempting to access an index beyond the length of the list.

68.

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 ?

a)

"e"

b)

"f"

c)

"h"

d)

"i"

69.

What are the contents of yourList after the code segment is executed?

a)

[10, 30, 50, 70]

b)

[20, 40, 60, 80]

c)

[10, 30, 50, 70, 20, 40, 60, 80]

d)

[20, 40, 60, 80, 10, 30, 50, 70]

70.

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?

a)

[ ]

b)

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

c)

["flute", "violin"]

d)

["flute", "violin", "guitar", "drums", "bass"]

71.

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

a)

-1

b)

"hello"

c)

2.5

d)

4

72.

A student is creating an algorithm to display the distance between the numbers num1 and num2 on a number line. The following table shows the distance for several different values.

Which of the following algorithms displays the correct distance for all possible values of num1 and num2 ?

a)

Step 1: Add num1 and num2 and store the result in the variable sum.

Step 2: Take the absolute value of sum and display the result.

b)

Step 1: Subtract num1 from num2 and store the result in the variable diff.

Step 2: Take the absolute value of diff and display the result.

c)

Step 1: Take the absolute value of num1 and store it in the variable absNum1.

Step 2: Take the absolute value of num2 and store it in the variable absNum2.

Step 3: Add absNum1 and absNum2 and display the result.

d)

Step 1: Take the absolute value of num1 and store it in the variable absNum1.

Step 2: Take the absolute value of num2 and store it in the variable absNum2.

Step 3: Subtract absNum1 from absNum2 and display the result.

73.

A teacher has a goal of displaying the names of 2 students selected at random from a group of 30 students in a classroom. Any possible pair of students should be equally likely to be selected. Which of the following algorithms can be used to accomplish the teacher’s goal?

a)

Step 1: Assign each student a unique integer from 1 to 30.

Step 2: Generate a random integer n from 1 to 15.

Step 3: Select the student who is currently assigned integer n and display the student’s name. Step 4: Generate a new random integer n from 16 to 30.

Step 5: Select the student who is currently assigned integer n and display the student’s name.

b)

Step 1: Assign each student a unique integer from 1 to 30.

Step 2: Generate a random integer n from 1 to 30.

Step 3: Select the student who is currently assigned integer n and display the student’s name. Step 4: Generate a new random integer n from 1 to 30.

Step 5: Select the student who is currently assigned integer n and display the student’s name.

c)

Step 1: Assign each student a unique integer from 1 to 30.

Step 2: Generate a random odd integer n from 1 to 29.

Step 3: Select the student who is currently assigned integer n and display the student’s name. Step 4: Generate a new random even integer n from 2 to 30.

Step 5: Select the student who is currently assigned integer n and display the student’s name.

d)

Step 1: Assign each student a unique integer from 1 to 30.

Step 2: Generate a random integer n from 1 to 30.

Step 3: Select the student who is currently assigned integer n and display the student’s name.

Step 4: The student who was selected in the previous step is assigned 0. All other students are reassigned a unique integer from 1 to 29.

Step 5: Generate a new random integer n from 1 to 29.

Step 6: Select the student who is currently assigned integer n and display the student’s name.

74.

What is displayed as a result of executing the code segment?

a)

10 20 30 40

b)

21 30 40 50

c)

21 40 30 40

d)

21 40 30 50

75.

The following code segment is used to determine whether a customer is eligible for a discount on a movie ticket.

val1 ← (NOT (category = "new")) OR (age ≥ 65)

val2 ← (category = "new") AND (age < 12)

If category is "new" and age is 20, what are the values of val1 and val2 as a result of executing the code segment?

a)

val1 = true , val2 = true

b)

val1 = true , val2 = false

c)

val1 = false , val2 = true

d)

val1 = false, val2 = false

76.

To attend a particular camp, a student must be either at least 13 years old or in grade 9 or higher, but must not yet be 18 years old. Let age represent a student’s age and let grade represent the student’s grade level. Which of the following expressions evaluates to true if the student is eligible to attend the camp and evaluates to false otherwise?

a)

((age ≥ 13) OR (grade ≥ 9)) AND (age ≤ 18)

b)

((age ≥ 13) OR (grade ≥ 9)) AND (age < 18)

c)

((age ≥ 13) OR (grade ≥ 9)) OR (age ≤ 18)

d)

((age ≥ 13) OR (grade ≥ 9)) OR (age < 18)

77.

Let n be an integer value. Which of the following expressions evaluates to true if and only if n is a two-digit integer (i.e., in the range from 10 to 99, inclusive)?

a)

n = (n MOD 100)

b)

(n ≥ 10) AND (n < 100)

c)

(n < 10) AND (n ≥ 100)

d)

(n > 10) AND (n < 99)

78.

To qualify for a particular scholarship, a student must have an overall grade point average of 3.0 or above and must have a science grade point average of over 3.2. Let overallGPA represent a student’s overall grade point average and let scienceGPA represent the student’s science grade point average. Which of the following expressions evaluates to true if the student is eligible for the scholarship and evaluates to false otherwise?

a)

(overallGPA > 3.0) AND (scienceGPA > 3.2)

b)

(overallGPA > 3.0) AND (scienceGPA ≥ 3.2)

c)

(overallGPA ≥ 3.0) AND (scienceGPA > 3.2)

d)

(overallGPA ≥ 3.0) AND (scienceGPA ≥ 3.2)

79.

In the following expression, the variable truckWeight has the value 70000 and the variable weightLimit has the value 80000.

truckWeight < weightLimit

What value does the expression evaluate to?

a)

70000

b)

80000

c)

true

d)

false

80.

What is displayed as a result of executing the code segment?

a)

true true true

b)

false false false

c)

true false true

d)

false false true

81.

A certain game keeps track of the maximum and minimum scores obtained so far. If num represents the most recent score obtained, which of the following algorithms correctly updates the values of the maximum and the minimum?

a)

If num is greater than the minimum, set the minimum equal to num . Otherwise, if num is greater than the maximum, set the maximum equal to num .

b)

If num is less than the minimum, set the minimum equal to num . Otherwise, if num is greater than the maximum, set the maximum equal to num .

c)

If num is less than the minimum, set the minimum equal to num . Otherwise, if num is less than the maximum, set the maximum equal to num .

d)

If num is greater than the minimum, set the minimum equal to num. Otherwise, if num is less than the maximum, set the maximum equal to num.

82.

A programmer is creating an algorithm that will be used to turn on the motor to open the gate in

a parking garage. The specifications for the algorithm are as follows.

The gate should not open when the time is outside of business hours.

The motor should not turn on unless the gate sensor is activated.

The motor should not turn on if the gate is already open.

Which of the following algorithms can be used to open the gate under the appropriate conditions?

a)

Check if the time is outside of business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is closed. If it is, turn on the motor.

b)

Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is, turn on the motor.

c)

Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is not, check if the gate is open. If it is not, turn on the motor.

d)

Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is not, turn on the motor.

83.

If the value of x is 3 and the value of y is 5, what is displayed as a result of executing the code segment?

a)

-2

b)

2

c)

8

d)

Nothing will be displayed.

84.

In a certain game, the integer variable bonus is assigned a value based on the value of the integer variable score.

If score is greater than 100, bonus is assigned a value that is 10 times score.

If score is between 50 and 100 inclusive, bonus is assigned the value of score.

If score is less than 50, bonus is assigned a value of 0.

Which of the following code segments assigns bonus correctly for all possible integer values of score ?

a)

IF(score > 100)

{

bonus ← score * 10

}

ELSE

{

IF(score ≥ 50)

{

bonus ← score

}

ELSE

{

bonus ← 0

}

b)

IF(score ≥ 50)

{

IF(score > 100)

{

bonus ← score * 10

}

ELSE

{

bonus ← 0

}

}

ELSE

{

bonus ← score

c)

IF(score < 50)

{

bonus ← 0

}

ELSE

{

IF(score ≥ 50)

{

bonus ← score

}

ELSE

{

bonus ← score * 10

}

d)

IF(score < 50)

{

bonus ← 0

}

ELSE

{

IF(score > 100)

{

bonus ← score * 10

}

ELSE

{

bonus ← score

}

85.

Under which of the following conditions will the value "C" be assigned to the variable grade ?

a)

When the value of exam is 70 and the value of presentation is 50

b)

When the value of exam is 70 and the value of presentation is 80

c)

When the value of exam is 80 and the value of presentation is 60

d)

When the value of exam is 80 and the value of presentation is 80

86.

If x has a value of 7 and y has a value of 20, what is displayed as a result of executing the code segment?

a)

One

b)

Two

c)

Three

d)

Four

87.

Consider the following code segment.

result ← 1

IF(score1 > 500)

{

result ← result + 1

IF(score2 > 500)

{

result ← result + 1

}

ELSE

{

result ← result + 2

}

}

ELSE

{

result ← result + 5

IF(score2 > 500)

{

result ← result + 1

}

ELSE

{

result ← result - 1

}

}

If the value of score1 is 350 and the value of score2 is 210, what will be the value of result after the code segment is executed?

a)

3

b)

4

c)

5

d)

7

88.

Suppose a large group of people in a room were all born in the same year. Consider the following three algorithms, which are each intended to identify the people in the room who have the earliest birthday based on just the month and day. For example, a person born on February 10 is considered to have an earlier birthday than a person born on March 5. Which of the three algorithms will identify the correct people?

l. All the people in the room stand up. All standing people form pairs where possible, leaving at most one person not part of a pair. For each pair, the person with the earlier birthday remains standing, while the other person in the pair sits down. If there is a tie, both people sit down. Any individual not part of a pair remains standing. Continue doing this until only one person remains standing. That person has the earliest birthday.

ll. All the people in the room stand up. All standing people form pairs with another standing person that they have not previously been paired with where possible, leaving at most one person not part of a pair. For each pair, the person with the earlier birthday remains standing, while the other person in the pair sits down. If there is a tie, both people in the pair remain standing. Any individual not part of a pair remains standing. Continue doing this until only one person remains standing or all persons standing have the same birthday. Anyone still standing has the earliest birthday.

lll. Beginning with the number 1, ask if anyone was born on that day of any month. Continue with the numbers 2, 3, and so on until a positive response is received. If only one person responds, that person has the earliest birthday. If more than one person responds, determine which person was born in the earliest month, and that person or those persons have the earliest birthday.

a)

l only

b)

ll only

c)

l and ll

d)

ll and lll

89.

Which of the following algorithms display all integers between 1 and 20, inclusive, that are not divisible by 3 ?

a)

Step 1: Set x to 0.

Step 2: Increment x by 1.

Step 3: If x is not divisible by 3, then display x .

Step 4: Repeat steps 2 and 3 until x is 20. ,

b)

Step 1: Set x to 0.

Step 2: If x is divisible by 3, then display x .

Step 3: Increment x by 1.

Step 4: Repeat steps 2 and 3 until x is greater than 20. ,

c)

Step 1: Set x to 1.

Step 2: If x is divisible by 3, then do nothing; otherwise display x .

Step 3: Increment x by 1.

Step 4: Repeat steps 2 and 3 until x is 20. ,

d)

Step 1: Set x to 1.

Step 2: If x is divisible by 3, then do nothing; otherwise display x.

Step 3: Increment x by 1.

Step 4: Repeat steps 2 and 3 until x is greater than 20.

90.

Which of the following can be used as a replacement for <MISSING STATEMENT> so that the code segment works as intended?

a)

REPEAT 1 TIMES

b)

REPEAT 2 TIMES

c)

REPEAT 3 TIMES

d)

REPEAT 4 TIMES

91.

The following grid contains a robot represented as a triangle, which is initially facing toward the top of the grid. The robot can move into a white or gray square but cannot move into a black region.

Which of the following code segments can be used to move the robot to the gray square?

a)

REPEAT 3 TIMES

{

MOVE_FORWARD()

}

REPEAT 2 TIMES

{

MOVE_FORWARD()

}

REPEAT 3 TIMES

{

MOVE_FORWARD()

}

b)

REPEAT 8 TIMES

{

MOVE_FORWARD()

c)

REPEAT 3 TIMES

{

MOVE_FORWARD()

}

ROTATE_LEFT()

REPEAT 2 TIMES

{

MOVE_FORWARD()

}

ROTATE_LEFT()

REPEAT 3 TIMES

MOVE_FORWARD()

}

d)

REPEAT 3 TIMES

{

MOVE_FORWARD()

}

ROTATE_LEFT()

REPEAT 2 TIMES

{

MOVE_FORWARD()

}

ROTATE_RIGHT()

REPEAT 3 TIMES

{

MOVE_FORWARD()

}

92.

What is the value of result after the code segment is executed?

a)

6

b)

10

c)

15

d)

21

93.

Which of the following algorithms will allow the robot to make a single circuit around the rectangular region of black squares, finishing in the exact location and direction that it started in each of the four grids?

a)

Step 1: Keep moving forward, one square at a time, until the square to the right of the robot is black.

Step 2: Turn right and move one square forward.

Step 3: Repeat steps 1 and 2 three more times.

b)

Step 1: Keep moving forward, one square at a time, until the square to the right of the robot is no longer black.

Step 2: Turn right and move one square forward.

Step 3: Repeat steps 1 and 2 three more times.

c)

Step 1: Move forward three squares.

Step 2: Turn right and move one square forward.

Step 3: If the square to the right of the robot is black, repeat steps 1 and 2.

d)

Step 1: Move forward three squares.

Step 2: Turn right and move one square forward.

Step 3: If the square to the right of the robot is not black, repeat steps 1 and 2.

94.

Three different numbers need to be placed in order from least to greatest. For example, if the numbers are ordered 9, 16, 4, they should be reordered as 4, 9, 16. Which of the following algorithms can be used to place any three numbers in the correct order?

a)

If the first number is greater than the last number, swap them. Then, if the first number is greater than the middle number, swap them.

b)

If the first number is greater than the middle number, swap them. Then, if the middle number is greater than the last number, swap them.

c)

If the first number is greater than the middle number, swap them. Then, if the middle number is greater than the last number, swap them. Then, if the first number is greater than the last number, swap them.

d)

If the first number is greater than the middle number, swap them. Then, if the middle number is greater than the last number, swap them. Then, if the first number is greater than the middle number, swap them.

95.

In the following code segment, assume that x and y have been assigned integer values.

sum ← 0

REPEAT x TIMES

{

REPEAT y TIMES

{

sum ← sum + 1

}

}

At the end of which of the following code segments is the value of sum the same as the value of sum at the end of the preceding code segment?

a)

sum ← 0

z ← x + y

REPEAT z TIMES

{

sum ← sum + 1

}

b)

sum ← 0

z ← x * y

REPEAT z TIMES

{

sum ← sum + 1

}

c)

sum ← 0

REPEAT x TIMES

{

sum ← sum + 1

}

REPEAT y TIMES

{

sum ← sum + 1

}

d)

sum ← 0

REPEAT y TIMES

{

REPEAT x TIMES

{

sum ← sum + 1

}

96.

Consider the goal of modifying the code segment to count the number of squares the robot visits before execution terminates. Which of the following modifications can be made to the code segment to correctly count the number of squares the robot moves to?

a)

Inserting the statement count ← count + 1 between line 6 and line 7

b)

Inserting the statement count ← count + 2 between line 6 and line 7

c)

Inserting the statement count ← count + 1 between line 8 and line 9

d)

Inserting the statement count ← count + n between line 8 and line 9

97.

When the robot reaches the gray square, it turns around and faces the bottom of the grid. Which of the following changes, if any, should be made to the code segment to move the robot back to its original position in the bottom-left square of the grid and facing toward the bottom of the grid?

a)

Interchange the ROTATE_RIGHT and the ROTATE_LEFT blocks.

b)

Replace ROTATE_RIGHT with ROTATE_LEFT .

c)

Replace ROTATE_LEFT with ROTATE_RIGHT .

d)

No change is needed; the algorithm is correct as is.

98.

What is displayed as a result of executing the code segment?

a)

1 3 5

b)

5 3 1

c)

100 300 500

d)

500 300 100

99.

Which of the following should replace <MISSING CODE> so that the code segment works as intended?

a)

IF(vote ≤ LENGTH(voteList))

b)

FOR EACH vote IN voteList

c)

REPEAT LENGTH(voteList) TIMES

d)

REPEAT UNTIL(vote > LENGTH(voteList))

100.

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.

What is the largest possible value that the variable x can have after the code segment executes?

a)

17

b)

14

c)

11

d)

4

101.

Which of the following can be used to replace <MISSING CODE> so that the code segment works as intended?

a)

APPEND(evenList, i)

i ← i + 2

b)

i ← i + 2

APPEND(evenList, i)

c)

APPEND(evenList, 2 * i)

i ← i + 1

d)

i ← i + 1

APPEND(evenList, 2 * i)

102.

What are the values of count1 and count2 as a result of executing the code segment?

a)

count1 = 2 , count2 = 2

b)

count1 = 2 , count2 = 3

c)

count1 = 3 , count2 = 2

d)

count1 = 5, count2 = 0

103.

A sorted list of numbers contains 200 elements. Which of the following is closest to the maximum number of list elements that will need to be examined when performing a binary search for a particular value in the list?

a)

5

b)

8

c)

100

d)

200

104.

A time stamp indicates the date and time that a measurement was taken. A data scientist has a list containing 10,000 time stamps, sorted in chronological order. Which of the following is closest to the maximum number of values that will need to be examined when performing a binary search for a value in the list?

a)

10

b)

15

c)

5,000

d)

10,000

105.

The list listOne is a sorted list of numbers that contains 700 elements. The list listTwo is a sorted list of numbers that contains 900 elements. Let x represent the maximum number of list elements that will need to be examined when performing a binary search for a value in listOne, and let y represent the maximum number of list elements that will need to be examined when performing a binary search for a value in listTwo. Which of the following statements about x and y is true?

a)

The value of x is approximately equal to the value of y .

b)

The value of x is approximately 10 less than the value of y .

c)

The value of x is approximately 13 less than the value of y .

d)

The value of x is approximately 200 less than the value of y.

106.

For which of the following lists can a binary search be used to search for an item in the list?

l. ["blue", "green", "jade", "mauve", "pink"]

ll. [5, 5, 5, 5, 6, 7, 8, 8, 8]

lll. [10, 5, 3, 2, -4, -8, -9, -12]

a)

l only

b)

lll only

c)

l and lll

d)

l, ll, and lll

107.

A large number of genetic codes are stored as binary values in a list. Which one of the following conditions must be true in order for a researcher to obtain the correct result when using a binary search algorithm to determine if a given genetic code is in the list?

a)

The genetic codes must be converted from binary to decimal numbers.

b)

The list must be sorted based on the genetic code values.

c)

The number of genetic code values in the list must be a power of 2.

d)

The number of genetic code values in the list must be even.

108.

Suppose that a list of numbers contains values [-4, -1, 1, 5, 2, 10, 10, 15, 30]. Which of the following best explains why a binary search should NOT be used to search for an item in this list?

a)

The list contains both positive and negative elements.

b)

The elements of the list are not sorted.

c)

The list contains an odd number of elements.

d)

The list contains duplicate elements.

109.

What is displayed as a result of executing the code segment?

a)

1 1 2 * 2

b)

1 ** 1 2 * 2

c)

1 ** 2 **

d)

** 1 ** 2

110.

What is displayed as a result of the procedure call proc2("birthday", "to you") ?

a)

birthday happy to you

b)

birthday happy birthday

c)

to you birthday happy

d)

to you happy birthday

111.

The device is positioned at the upper-left corner of a sheet of paper and is facing right. Which of the following code segments will produce the drawing shown?

a)

penDown()

goForward(10)

turnRight(90)

goForward(10)

turnRight(90)

b)

goForward(10)

penDown()

goForward(10)

penUp() t

urnRight(90)

turnRight(90)

penDown() goForward(10)

c)

penDown()

goForward(10)

turnRight(90)

penUp()

goForward(10)

turnRight(90)

penDown()

d)

penDown()

goForward(10)

penUp()

turnRight(90)

goForward(10)

turnRight(90)

penDown()

goForward(10)

112.

Consider the following procedure.

PROCEDURE doSomething(num1, num2)

{

DISPLAY(num1)

RETURN(num1)

DISPLAY(num2)

}

Consider the following statement.

DISPLAY(doSomething(10, 20))

What is displayed as a result of executing the statement above?

a)

10 10

b)

10 20

c)

10 10 20

d)

10 20 10

113.

Which of the following are benefits of procedural abstraction?

a)

Procedural abstraction prevents programmers from accidentally using the intellectual property of other programmers.

b)

Procedural abstraction eliminates the need for programmers to document their code.

c)

Procedural abstraction makes it easier for people to read computer programs. Rationale: Correct. Procedural abstraction helps improve code readability.

d)

Procedural abstraction provides an opportunity to give a name to a block of code that describes the purpose of the code block.

114.

A student has a data file containing 10,000 numerical values. The student is writing a program to compute the average of the numbers contained in the file. Which of the following procedures is most likely to be useful in the student’s program?

a)

A procedure that returns the quotient when dividing one value by another

b)

A procedure that returns the sum when adding one value to another

c)

A procedure that returns the sum of the values in the file

d)

A procedure that returns true if the file contains any duplicate values and returns false otherwise

115.

A student is writing a program that is intended to replace each negative value in a particular column of a spreadsheet with the value 0. Which of the following procedures is most likely to be useful in the student’s program?

a)

A procedure containsNegatives , which returns true if any negative values appear in the column and returns false otherwise.

b)

A procedure countNegatives , which returns the number of negative values that appear in the column.

c)

A procedure findNegative , which returns the row number of the first negative value that appears in the column or -1 if there are no negative values.

d)

A procedure minimum, which returns the minimum value that appears in the column.

116.

Which of the following procedures would be most useful as part of a program to determine whether a word appears in two different text files?

a)

A procedure getWords , which takes a positive integer n and a text file as input and returns the first n words in the text file.

b)

A procedure isFound , which takes a word and a text file as input and returns true if the word appears in the text file

c)

A procedure textMatch , which takes two text files as input and returns true if the two text files are identical.

d)

A procedure sameSize, which takes two text files as input and returns true if the two text files contain the same number of words.

117.

Which of the following CANNOT be displayed as a result of executing the code segment?

a)

1 1 1 1

b)

1 2 3 2

c)

1 2 3 4

d)

1 3 2 4

118.

Which of the following describes the possible values of ans as a result of executing the code segment?

a)

Any integer value from 1 to 8 , inclusive

b)

Any integer value from 1 to 16 , inclusive

c)

Any integer value from 4 to 8 , inclusive

d)

Any integer value from 7 to 16, inclusive

119.

Which of the following is NOT a possible output of this simulation?

a)

The player had 1 bonus round attempts and 1 of them earned extra points.

b)

The player had 2 bonus round attempts and 0 of them earned extra points.

c)

The player had 3 bonus round attempts and 7 of them earned extra points.

d)

The player had 4 bonus round attempts and 3 of them earned extra points.

120.

A spinner contains 12 regions of equal size. The regions are numbered 1 to 12. Which of the following code segments can be used to simulate the results of spinning the spinner three times and assigns the sum of the values obtained by the three spins to the variable sum ?

a)

sum ← RANDOM(1, 12) + RANDOM(1, 12) + RANDOM(1, 12)

b)

sum ← RANDOM(1, 36)

c)

sum ← 3 * RANDOM(1, 12)

d)

sum ← 12 * RANDOM(1, 3)

121.

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

a)

A simulation allows investigation of a phenomenon without the real-world limitations on time, safety, or budget.

b)

A simulation can be used to model real-world events that are impractical for experiments.

c)

A simulation always produces the same output, so its results can be verified.

d)

A simulation produces results that are more accurate than experimental results.

122.

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?

a)

The model used by the simulation software cannot be modified once the simulation has been used.

b)

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

c)

Running a simulation requires more time to generate data from trials than observing the crowd exiting the arena at various events.

d)

Running a simulation requires a large number of observations to be collected before it can be used to explore a problem.

123.

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

a)

Determining the longest word in a textbook

b)

Minimizing the customer wait times at a bank

c)

Predicting the outcomes of weather patterns

d)

Studying the formation of a galaxy

124.

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

a)

An engineering company wants to test whether a change to a car design will negatively affect fuel efficiency.

b)

An insurance company wants to study the effect of cold weather patterns on health-care costs.

c)

A manufacturing company wants to determine whether using robots in its facility will increase productivity.

d)

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

125.

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

a)

Determining the average grade of the students in a certain class

b)

Keeping track of the high score in a game

c)

Investigating ways to reduce the amount of trash in the ocean

d)

Studying the effect of a genetic change in a population

126.

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?

a)

A simulation cannot be used to test the train under varying weather conditions.

b)

Implementing a simulation is likely to increase the overall costs associated with the project.

c)

Other high-speed train routes have been constructed in other locations, so a simulation is not needed.

d)

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

127.

For which of the following situations would it be best to use a heuristic in order to find a solution that runs in a reasonable amount of time?

a)

Appending a value to a list of n elements, which requires no list elements be examined.

b)

Finding the fastest route that visits every location among n locations, which requires n! possible routes be examined.

c)

Performing a binary search for a score in a sorted list of n scores, which requires that fewer than n scores be examined.

d)

Performing a linear search for a name in an unsorted database of n people, which requires that up to n entries be examined.

128.

A team of programmers is designing software. One portion of the project presents a problem for which there is not an obvious solution. After some research, the team determines that the problem is undecidable. Which of the following best explains the consequence of the problem being undecidable?

a)

The problem can be solved algorithmically, but it will require an unreasonably long amount of time.

b)

The problem can be solved algorithmically, but it will require an unreasonably large amount of data storage.

c)

There is no possible algorithm that can be used to solve all instances of the problem.

d)

There are several different possible algorithms that can solve the problem, but there is controversy about which is the most efficient.

129.

A student wants to determine whether a certain problem is undecidable. Which of the following will demonstrate that the problem is undecidable?

a)

Show that for one instance of the problem, an algorithm can be written that is always capable of providing a correct yes-or-no answer.

b)

Show that for one instance of the problem, no algorithm can be written that is capable of providing a correct yes-or-no answer.

c)

Show that for one instance of the problem, a heuristic is needed to write an algorithm that is capable of providing a correct yes-or-no answer.

d)

Show that for one instance of the problem, an algorithm that runs in unreasonable time can be written that is capable of providing a correct yes-or-no answer.

130.

Which of the following best explains how algorithms that run on a computer can be used to solve problems?

a)

All problems can be solved with an algorithm that runs in a reasonable amount of time.

b)

All problems can be solved with an algorithm, but some algorithms might need a heuristic to run in a reasonable amount of time.

c)

All problems can be solved with an algorithm, but some algorithms might run in an unreasonable amount of time.

d)

Some problems cannot be solved by an algorithm.

131.

a)

A

b)

B

c)

C

d)

D

132.

a)

A

b)

B

c)

C

d)

D

133.

a)

A

b)

B

c)

C

d)

D

134.

a)

A

b)

B

c)

C

d)

D

135.

a)

A

b)

B

c)

C

d)

D

136.

a)

A

b)

B

c)

C

d)

D

137.

a)

A

b)

B

c)

C

d)

D

138.

a)

A

b)

B

c)

C

d)

D

139.

a)

A

b)

B

c)

C

d)

D

140.

a)

A

b)

B

c)

C

d)

D

141.

a)

A

b)

B

c)

C

d)

D

142.

a)

A

b)

B

c)

C

d)

D