AP CSP Review Test - Aydin Sheikh

Ace your homework & exams now with Quizwiz!

A student wrote the following program to remove all occurrences of the strings "the" and "a" from the list wordList. While debugging the program, the student realizes that the loop never terminates. Which of the following changes can be made so that the program works as intended?

Inserting index ← index - 1 between lines 6 and 7

A small team of wildlife researchers is working on a project that uses motion-activated field cameras to capture images of animals at study sites. The team is considering using a "citizen science" approach to analyze the images. Which of the following best explains why such an approach is considered useful for this project?

The image analysis is likely to take a longer time for the research team than for a distributed group of individuals.

A video-streaming service maintains a database of information about its customers and the videos they have watched. The program below analyzes the data in the database and compares the number of viewers of science fiction videos to the number of viewers of videos of other genres. It uses the procedure , which returns the number of unique users who viewed videos of a given category in the past year. The procedure takes approximately 1 hour to return a result, regardless of the number of videos of the given genre. All other operations happen nearly instantaneously.

5 hours

Which of the following are true statements about how the Internet enables crowdsourcing? I. The Internet can provide crowdsourcing participants access to useful tools, information, and professional knowledge. II. The speed and reach of the Internet can lower geographic barriers, allowing individuals from different locations to contribute to projects. III. Using the Internet to distribute solutions across many users allows all computational problems to be solved in reasonable time, even for very large input sizes. Responses

1 and 2 only

Grades in a computer science course are based on total points earned on a midterm exam and a final exam. The teacher provides a way for students to improve their course grades if they receive high scores on the final exam: if a student's final exam score is greater than the student's midterm exam score, the final exam score replaces the midterm exam score in the calculation of total points. The table below shows two students' scores on the midterm and final exams and the calculated total points each student earns. For each student, the data contain the student name, the midterm exam score, the final exam score, and the result of the total points calculation. Which of the following could be determined from the data? I. The average total points earned per studentII. The average increase in total points per student as a result of the score replacement policyIII. The proportion of students who improved their total poin

1, 2, and 3

The figure below shows two possible network configurations for devices P through V. A line between two devices indicates a connection. Devices can communicate only through the connections shown. In configuration I, what is the minimum number of connections that must be broken or removed before device T can no longer communicate with device U?

2

Internet protocol version 4 (IPv4) represents each IP address as a 32-bit binary number. Internet protocol version 6 (IPv6) represents each IP address as a 128-bit binary number. Which of the following best describes the result of using 128-bit addresses instead of 32-bit addresses?

2^96 times as many addresses are available.

A text-editing application uses binary sequences to represent each of 200 different characters. What is the minimum number of bits needed to assign a unique bit sequence to each of the possible characters?

8

Which of the following best explains how a certificate authority is used in protecting data?

A certificate authority verifies the authenticity of encryption keys used in secured communications.

The following procedure is intended to return true if at least two of the three parameters are equal in value and is intended to return false otherwise. PROCEDURE AnyPairs (x, y, z) { IF (x = y) { RETURN (true) } ELSE { RETURN (y = z) } } For which of the following procedure calls does the procedure NOT return the intended value? Responses

AnyPairs ("bat", "cat", "bat")

The figure below shows two possible network configurations for devices P through V. A line between two devices indicates a connection. Devices can communicate only through the connections shown. In which of the configurations is it possible to have redundant routing between devices Q and V?

Both configuration I and configuration II

Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in the string more than once and replaces each instance of that pair with a corresponding character that does not appear in the string. The algorithm saves a list containing the mapping of character pairs to their corresponding replacement characters. For example, the string can be encoded as by replacing all instances of with and replacing all instances of with . Which of the following statements about byte pair encoding is true?

Byte pair encoding is an example of a lossless transformation because an encoded string can be restored to its original version.

The two code segments below are each intended to display the average of the numbers in the list . Assume that contains more than one value. Which of the following best describes the two code segments?

Code segment II displays the correct average, but code segment I does not.

Which of the following best explains how data is transmitted on the Internet?

Data is broken into packets, which can be sent along different paths.

In mathematics, a perfect number is a type of integer. The procedure IsPerfect (num) returns true if num is a perfect number and returns false otherwise. The following program is intended to count and display the number of perfect numbers between the integers start and end, inclusive. Assume that start is less than end. The program does not work as intended. Line 1: currentNum ← start Line 2: count ← 0 Line 3: REPEAT UNTIL (currentNum > end) Line 4: { Line 5: count ← count + 1 Line 6: IF (IsPerfect (currentNum)) Line 7: { Line 8: count ← count + 1 Line 9: currentNum ← currentNum + 1 Line 10: } Line 11: currentNum ← currentNum + 1 Line 12: } Line 13: DISPLAY (count) Which two lines of code should be removed so that the program will work as intended?

Line 5 and Line 9

Assume that the list of numbers nums has more than 10 elements. The program below is intended to compute and display the sum of the first 10 elements of nums. Line 1: i ← 1 Line 2: sum ← 0 Line 3: REPEAT UNTIL (i > 10) Line 4: { Line 5: i ← i + 1 Line 6: sum ← sum + nums[i] Line 7: } Line 8: DISPLAY (sum) Which change, if any, is needed for the program to work as intended?

Lines 5 and 6 should be interchanged.

A file storage application allows users to save their files on cloud servers. A group of researchers gathered user data for the first eight years of the application's existence. Some of the data are summarized in the following graphs. The line graph on the left shows the number of registered users each year. The line graph on the right shows the total amount of data stored by all users each year. The circle graph shows the distribution of file sizes currently stored by all users. Which of the following observations is most consistent with the information in the circle graph?

Over 75% of the files stored are 10 MB in size or less.

A media librarian at a movie studio is planning to save digital video files for archival purposes. The movie studio would like to be able to access full-quality videos if they are needed for future projects. Which of the following actions is LEAST likely to support the studio's goal?

Using lossy compression software to reduce the size requirements of the data being stored

A musician is creating a song using audio samples. Which of the following actions will minimize the risk of a copyright violation when creating sample-based music?

Using samples published with a no-rights-reserved Creative Commons license

Consider the following spinner, which is used to determine how pieces are to be moved on a game board. The region labeled "Move 1 space" is six times as large as each of the other two regions. Which of the following code segments can be used to simulate the behavior of the spinner?

if spin = 1, lose a turn, else (if spin = 2, move 2 spaces, else move 1 space)

A flowchart is a way to visually represent an algorithm. The flowchart below is used by an apartment rental Web site to set the variable to for apartments that meet certain criteria. Which of the following statements is equivalent to the algorithm in the flowchart?

include = (floor > 10) OR (bedrooms = 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?

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

The procedure Smallest is intended to return the least value in the list . The procedure does not work as intended. For which of the following values of theList will Smallest(theList) NOT return the intended value?

thelist = [30,40,20,10] and thelist = [40,30,20,10]

The procedure NumOccurrences is intended to count and return the number of times targetWord appears in the list wordList. The procedure does not work as intended. For which of the following code segments will the call to NumOccurrences NOT return the intended value?

treelist = (birch, maple, birch) and numOccurences (treeList, birch) treelist = (birch, maple, oak) and numOccurences (treelist, maple)

A biologist wrote a program to simulate the population of a sample of bacteria. The program uses the following procedures. Procedure CallExplanationInitialPopulation ()Returns the number of bacteria at the start of the simulationNextPopulation (currPop)Based on the current value of currPop, returns the number of bacteria after one hour Code for the simulation is shown below. hours ← 0 startPop ← InitialPopulation () currentPop ← startPop REPEAT UNTIL ((hours ≥ 24) OR (currentPop ≤ 0)) { currentPop ← NextPopulation (currentPop) hours ← hours + 1 } DISPLAY (currentPop - startPop) Which of the following are true statements about the simulation? 1. The simulation continues until either 24 hours pass or the population reaches 0. 2. The simulation displays the average change in population per hour over the course of the simulation. 3. The simulation displays the total population at the end of the simulation.

I only

Consider the following algorithms. Each algorithm operates on a list containing n elements, where n is a very large integer. An algorithm that accesses each element in the list twice An algorithm that accesses each element in the list n times An algorithm that accesses only the first 10 elements in the list, regardless of the size of the list Which of the algorithms run in reasonable time? Responses

I, II, and III

Consider two lists of numbers called list1 and list2. A programmer wants to determine how many different values appear in both lists. For example, if list1 contains [10, 10, 20, 30, 40, 50, 60] and list2 contains [20, 20, 40, 60, 80], then there are three different values that appear in both lists (20, 40, and 60). The programmer has the following procedures available. Procedure CallExplanationCombine (myList1, myList2)This procedure creates a new list containing the elements from myList1 ​followed by the entries from myList2. The resulting list is returned. For example, if myList1 contains [2, 4, 6] and myList2 contains [1, 5], the procedure will return the list [2, 4, 6, 1, 5].RemoveAllDups (myList)This procedure creates a new list containing the elements of myList with any duplicate values removed. The resulting list is returned. For example, if myList contains [3, 2, 4, 2, 2, 5, 6, 4], the procedure will return

newList1 ← RemoveAllDups (list1) newList2 ← RemoveAllDups (list2) bothList ← Combine (newList1, newList2) uniqueList ← RemoveAllDups (bothList) count ← LENGTH (bothList) - LENGTH (uniqueList)

A company delivers packages by truck and would like to minimize the length of the route that each driver must travel in order to reach 𝑛 delivery locations. The company is considering two different algorithms for determining delivery routes. Algorithm IGenerate all possible routes, compute their lengths, and then select the shortest possible route. This algorithm does not run in reasonable time.Algorithm IIStarting from an arbitrary delivery location, find the nearest unvisited delivery location. Continue creating the route by selecting the nearest unvisited location until all locations have been visited. This algorithm does not guarantee the shortest possible route and runs in time proportional to 𝑛2. Which of the following best categorizes algorithm II?

Algorithm II uses a heuristic approach to provide an approximate solution in reasonable time.

Which of the following would be the best use of citizen science?

An experiment that requires data measurements to be taken in many different locations

Which of the following best explains how symmetric encryption algorithms are typically used?

Symmetric encryption uses a single key that should be kept secret. The same key is used for both encryption and decryption of data.

Which of the following is an example of symmetric encryption?

Finn and Gwen develop a system that maps each letter of the alphabet to a unique symbol using a secret key. Finn uses the key to write a message to Gwen where each letter is replaced with the corresponding symbol. Gwen uses the key to map each symbol back to the original letter.

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.

A programmer notices the following two procedures in a library. The procedures do similar, but not identical, things. Procedure MaxTwo (x, y) returns the greater of its two integer parameters. Procedure MaxThree (x, y, z) returns the greatest of its three integer parameters. Which of the following procedures is a generalization of the MaxTwo and MaxThree procedures?

Procedure Max (numList), which returns the maximum value in the list of integers numList

A programmer notices the following two procedures in a library. The procedures do similar, but not identical, things. Procedure Square(n) returns the value n^2 Procedure Cube(n) returns the value n^3 Which of the following procedures is a generalization of the procedures described above?

Procedure Power(n,m) which returns the value n^m

Consider the two programs below. Which of the following best compares the values displayed by programs A and B?

Program A and program B display identical values in the same order.

Which of the following is a true statement about the use of public key encryption in transmitting messages?

Public key encryption enables parties to initiate secure communications through an open medium, such as the Internet, in which there might be eavesdroppers.

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.

A video-streaming Web site keeps count of the number of times each video has been played since it was first added to the site. The count is updated each time a video is played and is displayed next to each video to show its popularity. At one time, the count for the most popular video was about two million. Sometime later, the same video displayed a seven-digit negative number as its count, while the counts for the other videos displayed correctly. Which of the following is the most likely explanation for the error?

The count for the video became larger than the maximum value allowed by the data type used to store the count.

A social media site allows users to send messages to each other. A group of researchers gathered user data for the first 10 years of the site's existence. Some of the data are summarized in the table below, along with some of the company milestones.

The mobile app release led to users tending to write shorter messages.

A researcher wrote a program to simulate the number of mice in an environment that contains predators. The program uses the following procedures. Based on the code, which of the following assumptions is made in the simulation?

The number of predators does not change from day to day.

Which of the following is NOT an advantage of using open-source software?

The original developer of open-source software provides free or low-cost support for users installing and running the software.

A student wrote the procedure below, which is intended to ask whether a user wants to keep playing a game. The procedure does not work as intended. Which of the following best describes the result of running the procedure?

The procedure returns false no matter what the input is.

An online game collects data about each player's performance in the game. A program is used to analyze the data to make predictions about how players will perform in a new version of the game. The procedure GetPrediction (idNum) returns a predicted score for the player with ID number idNum. Assume that all predicted scores are positive. The GetPrediction procedure takes approximately 1 minute to return a result. All other operations happen nearly instantaneously. Two versions of the program are shown below. Version I topScore ← 0 idList ← [1298702, 1356846, 8848491, 8675309] FOR EACH id IN idList { score ← GetPrediction (id) IF (score > topScore) { topScore ← score } } DISPLAY (topScore) Version II idList ← [1298702, 1356846, 8848491, 8675309] topID ← idList[1] FOR EACH id IN idList { IF (GetPrediction (id) > GetPrediction (topID)) { topID ← id } } DISPLAY (GetPrediction (topID)) Which of the following

Version II requires approximately 5 more minutes to execute than version I.

The diagram below shows a circuit composed of three logic gates. Each gate takes two inputs and produces a single output.

a = true, b = false, c = false, d = false


Related study sets

AP Euro- Chapter 13 Reformation AP Exam Review Quiz

View Set

IPC unit 10 Detecting Sound vocab

View Set

2 (2) Financial Planning Industry In Malaysia

View Set

THE GAME OF CHESS and THE FEUDAL SYSTEM

View Set

Musculoskeletal Study Questions - Brunner and Suddarth

View Set

Ch 3 Section C: Aerodynamics of Maneuvering Flight

View Set