ap computer science ap test

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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

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

Which of the following best explains how IP addresses are assigned?

As a new device is connected to the Internet, it is assigned an IP address to enable communication on the network.

Convert 129 to an 8 bit binary number. a. 10001001 b. 11000001 c. 10001001 d. 10000001

d. 10000001

Which of the following best describes the ability of parallel computing solutions to improve efficiency?

the efficiency of a solution that can be broken down into parallel portions is still limited by a sequential portion

Which of the following best describes a direct benefit in using redundant routing on the Internet?

Redundancy often allows messages to be sent on the network even if some network devices or connections have failed.

The number of digital colors is limited by bits per pixel, whereas analog colors are unlimited. True False

True

A biologist wrote a program to simulate the population of a sample of bacteria. The program uses the following procedures. 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? The simulation continues until either 24 hours pass or the population reaches 0. The simulation displays the average change in population per hour over the course of the simulation. The simulation displays the total population at the end of the simulation. a. I only b. II only c. III only d. I and II

a. I only

According to the domain name system (DNS), which of the following is a subdomain of the domain example.com?

about.example.com

K bits in a sequence yield have many symbols? a. K b. K^2 c. 2 d. 2^K

d. 2^K

In a certain computer program, two positive integers are added together, resulting in an overflow error. Which of the following best explains why the error occurs?

The program can only use a fixed number of bits to represent integers; the computed sum is greater than the maximum representable value.

How many total numbers can be represented with an 4-bit binary (base-2) system? a. 256 b. 16 c. 32 d. 64

b. 16

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?

Compressing the file using a lossless compression algorithm before uploading it

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.

Which of the following best describes the role of the Internet engineering task force?

Developing standards and protocols for Internet communication

Your computer uses 5 bits to represent decimal numbers (0, 1, 2, 3, 4 and so on) in binary. What is the SMALLEST number for which an overflow error occur? a. 32 b. 28 c. 17 d. 16

a. 32

What's the largest number that can be represented in 4 bits? a. 12 b. 15 c. 16 d. 5

b. 15

he code fragment below is intended to display "odd" if the positive number num is odd. Which of the following can be used to replace <MISSING CONDITION> so that the code fragment will work as intended? a. (num MOD 1) = 0 b. (num MOD 1) = 1 c. (num MOD 2) = 0 d. (num MOD 2) = 1

d. (num MOD 2) = 1

Video should use lossless compression because it usually has a large file size which we need to reduce so we don't use up all our data. True False

False

A user unintentionally installs keylogging software on a computer. Which of the following is an example of how the keylogging software can be used by an unauthorized individual to gain access to computing resources? (A) The software gives an unauthorized individual remote access to the computer, allowing the individual to search the computer for personal information. (B) The software installs a virus on the computer and prompts the user to make a payment to the unauthorized individual to remove the virus. (C) The software prompts the user to enter personal information to verify the user's identity. This personal information is recorded and transmitted to an unauthorized individual. (D) The software records all user input on the computer. The recorded information is transmitted to an unauthorized individual, who analyzes it to determine the user's login passwords.

(D) The software records all user input on the computer. The recorded information is transmitted to an unauthorized individual, who analyzes it to determine the user's login passwords.

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? (A) Using samples found on popular music-streaming sites (B) Using samples found on peer-to-peer networks (C) Using samples from nondigital sound sources (vinyl records, tapes, etc.) (D) Using samples published with a no-rights-reserved Creative Commons license

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

ASCII is a character encoding scheme that uses 7 bits to represent each character. The decimal (base 10) values 65 through 90 represent the capital letters A through Z, as shown in the table below. What ASCII character is represented by the binary (base 2) number 1001010?

J

A flowchart is a way to visually represent an algorithm. The flowchart below uses the following building blocks. What is displayed as a result of executing the algorithm in the flowchart? a. 5 b. 15 c. 1234 d. 12345

a. 5

Which of the following is a true statement about the use of public key encryption in transmitting messages? a. Public key encryption enables parties to initiate secure communications through an open medium, such as the Internet, in which there might be eavesdroppers. b. Public key encryption is not considered a secure method of communication because a public key can be intercepted. c. Public key encryption only allows the encryption of documents containing text; documents containing audio and video must use a different encryption method. d. Public key encryption uses a single key that should be kept secure because it is used for both encryption and decryption.

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

Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. 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? a. include <--- (floor > 10) OR (bedrooms = 3) b. include <--- (floor > 10) AND (bedrooms = 3) c. INCLUDE <--- (FLOOR <=10) OR (bedrooms = 3) d. INCLUDE <--- (FLOOR <=10) AND (bedrooms = 3)

a. include <--- (floor > 10) OR (bedrooms = 3)

Convert 23 to a binary 8 bit number. a. 10010111 b. 00010111 c. 10001011 d. 00011111

b. 00010111

A student wrote the following code for a guessing game. While debugging the code, the student realizes that the loop never terminates. The student plans to insert the instruction somewhere in the code. Where could be inserted so that the code segment works as intended? a. Between line 6 and line 7 b. Between line 9 and line 10 c. Between line 20 and 21 d. Between line 21 and 22

b. Between line 9 and line 10

Which of the following CANNOT be displayed as a result of executing the code segment? a. 1111 b. 1232 c. 1234 d. 1324

d. 1324

Which of the following is NOT an advantage of using open-source software? (A) Open-source software is generally free or lower in cost than commercially available software. (B) The availability of source code makes it possible to customize open-source software to a user's individual needs. (C) The original developer of open-source software provides free or low-cost support for users installing and running the software. (D) Unlike commercial software, which can become obsolete when the company that created it goes out of business, open-source software can be updated without the involvement of the original programmers.

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

Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. A student wrote the following code for a guessing game. While debugging the code, the student realizes that the loop never terminates. The student plans to insert the instruction somewhere in the code. Where could be inserted so that the code segment works as intended? a. Between line 6 and line 7 b. Between line 9 and line 10 c. Between line 20 and 21 d. Between line 21 and 22

b. Between line 9 and line 10

Which of the following is a true statement about data compression? a. Data compression is only useful for files being transmitted over the Internet. b. Regardless of the compression technique used, once a data file is compressed, it cannot be restored to its original state. c. Sending a compressed version of a file ensures that the contents of the file cannot be intercepted by an unauthorized user. d. There are trade-offs involved in choosing a compression technique for storing and transmitting data.

d. There are trade-offs involved in choosing a compression technique for storing and transmitting data.

Which of the following is considered an unethical use of computer resources? (A) Downloading freeware or shareware onto your home computer (B) Purchasing a game from an app store and downloading it directly to a mobile device (C) Purchasing a single-user copy of photo editing software and installing it on all the computers in a computer lab (D) Searching online for an electronic version of a school textbook

(C) Purchasing a single-user copy of photo editing software and installing it on all the computers in a computer lab

A search engine has a trend-tracking feature that provides information on how popular a search term is. The data can be filtered by geographic region, date, and category. Categories include arts and entertainment, computers and electronics, games, news, people and society, shopping, sports, and travel. Which of the following questions is LEAST likely to be answerable using the trends feature? (A) In what month does a particular sport receive the most searches? (B) In which political candidates are people interested? (C) What is the cost of a certain electronics product? (D) Which region of the country has the greatest number of people searching for opera performances?

(C) What is the cost of a certain electronics product?

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?

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

Directions: For the question or incomplete statement below, two of the suggested answers are correct. For this question, you must select both correct choices to earn credit. No partial credit will be earned if only one correct choice is selected. Select the two that are best in each case. Which of the following Boolean expressions are equivalent to the expression ? Select two answers. a. (number > 15) AND (num = 15) b. (number > 15) OR (num = 15) c. NOT (num <15) d. NOT (NUM < 16)

b. (number > 15) OR (num = 15) c. NOT (num <15)

Which of the following is true of intellectual property? a. Information created on a computer is not owned by anyone since only analog information is protected under copyright law. b. Creative Commons has severely hindered broad and open access to digital information c. Creative Commons enables content creators to freely distribute their otherwise copyrighted work. d. You do not need to cite work created by someone else if both the original work and your use of it are in digital form.

c. Creative Commons enables content creators to freely distribute their otherwise copyrighted work.

What does lossy compression do to files? a. Increases file size and keeps the same quality b. eliminates no data at all c. Eliminates unnecessary info in a file to reduce file size d. Decreases file size and keeps the same quality

c. Eliminates unnecessary info in a file to reduce file size

Which of the following best describes the impact of Creative Commons? (A) Creative Commons gives creators of digital content the ability to indicate how their works can be legally used and distributed, enabling broad access to digital information. (B) Creative Commons gives Internet users the right to legally use and distribute any previously copyrighted work, enabling broad access to digital information. (C) Create Commons provides lossless transmission of messages, enabling reliable distribution of digital information. (D) Creative Commons provides private transmission of messages, enabling secure distribution of digital information.

(A) Creative Commons gives creators of digital content the ability to indicate how their works can be legally used and distributed, enabling broad access to digital information.

A mobile game tracks players' locations using GPS. The game offers special in-game items to players when they visit real-world points of interest. Which of the following best explains how bias could occur in the game? (A) Points of interest may be more densely located in cities, favoring players in urban areas over players in rural areas. (B) Some players may engage in trespassing, favoring players in urban areas over players in rural areas. (C) Special items may not be useful to all players, favoring players in urban areas over players in rural areas. (D) Weather conditions may be unpredictable, favoring players in urban areas over players in rural areas.

(A) Points of interest may be more densely located in cities, favoring players in urban areas over players in rural areas.

An individual receives an e-mail that appears to be from an insurance company. The message offers a low insurance rate, and prompts the recipient to click a link to learn more. Which of the following is most indicative that the e mail is part of a phishing attempt? (A) After clicking the link, a browser cookie is downloaded to the recipient's computer. (B) After clicking the link, a Web page opens that prompts the recipient for personal information. (C) After clicking the link, the recipient's private network becomes publicly visible via a rogue access point. (D) After clicking the link, software is installed on the recipient's computer that records every keystroke

(B) After clicking the link, a Web page opens that prompts the recipient for personal information.

Which of the following actions is most likely to help reduce the digital divide? (A) Adding a requirement that all users of a popular social media site link their accounts with a phone number. (B) Deploying satellites and other infrastructure to provide inexpensive Internet access to remote areas of Earth (C) Digitizing millions of books from university libraries, making their full text available online (D) Offering improved Internet connections to Internet users who are willing to pay a premium fee for more bandwidth

(B) Deploying satellites and other infrastructure to provide inexpensive Internet access to remote areas of Earth

Which of the following is an example of symmetric encryption? (A) Evy buys a locked box that operates using two different codes. When the first code is entered, a slot opens that allows a message to be put in the box. When the second code is entered, the door to the box opens. Evy gives the first code to her friends so they can leave messages for her and keeps the second code to herself so that she is the only one who can retrieve the messages. (B) 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. (C) Hannah writes a message to send to Isabel and hides the message under a rock behind the soccer field. Hannah gives Isabel the exact location of the rock so that only Isabel can find the message. Juan writes a message to send to Kelly and slides the message through a slot in the front of Kelly's locker. (D) Juan knows that Kelly has not shared her locker combination with anyone, so no one other than Kelly will be able to read the message.

(B) 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 city maintains a database of all traffic tickets that were issued over the past ten years. The tickets are divided into the following two categories. • Moving violations • Nonmoving violations The data recorded for each ticket include only the following information. • The month and year in which the ticket was issued • The category of the ticket Which of the following questions CANNOT be answered using only the information in the database? (A) Have the total number of traffic tickets per year increased each year over the past ten years? (B) In the past ten years, were nonmoving violations more likely to occur on a weekend than on a weekday? (C) In the past ten years, were there any months when moving violations occurred more often than nonmoving violations? (D) In how many of the past ten years were there more than one million moving violations?

(B) In the past ten years, were nonmoving violations more likely to occur on a weekend than on a weekday?

A software company is designing a mobile game system that should be able to recognize the faces of people who are playing the game and automatically load their profiles. Which of the following actions is most likely to reduce the possibility of bias in the system? (A) Testing the system with members of the software company's staff (B) Testing the system with people of different ages, genders, and ethnicities (C) Testing the system to make sure that the rules of the game are clearly explained (D) Testing the system to make sure that players cannot create multiple profiles

(B) Testing the system with people of different ages, genders, and ethnicities

Which of the following is most likely to be a data privacy concern for RunRoutr users? (A) Users of the application are required to carry their smartphones with them while running in order to enable all of the application's features. (B) Users of the application may have the ability to determine information about the locations of users that are not on their contact lists. (C) Users of the application may not be able to accurately track their running history if they share their smartphone with another family member. (D) Users of the application may not be compatible with any other users in their area.

(B) Users of the application may have the ability to determine information about the locations of users that are not on their contact lists.

Which of the following statements is most likely true about the differences between the basic version and the premium version of StreamPal? (A) Users of the basic version of StreamPal are more likely to give songs higher ratings than are users of the premium version of StreamPal. (B) Users of the basic version of StreamPal indirectly support StreamPal by allowing themselves to receive advertisements. (C) Users of the basic version of StreamPal spend more on monthly fees than do users of the premium version of StreamPal. (D) Users of the basic version of StreamPal use less data storage space on their devices than do users of the premium version of StreamPal.

(B) Users of the basic version of StreamPal indirectly support StreamPal by allowing themselves to receive advertisements.

Which of the following best explains how devices and information can be susceptible to unauthorized access if weak passwords are used? (A) Unauthorized individuals can deny service to a computing system by overwhelming the system with login attempts. (B) Unauthorized individuals can exploit vulnerabilities in compression algorithms to determine a user's password from their decompressed data. (C) Unauthorized individuals can exploit vulnerabilities in encryption algorithms to determine a user's password from their encryption key. (D) Unauthorized individuals can use data mining and other techniques to guess a user's password.

(D) Unauthorized individuals can use data mining and other techniques to guess a user's password.

A video streaming Web site uses 32 bit integers to count the number of times each video has been played. In anticipation of some videos being played more times than can be represented with 32 bits, the Web site is planing to change to 64 bit integers for the counter. Which of the following best describes the result of using 64 bit integers instead of 32 bit integers

2^32 times as many values can be represented.

Internet protocol version 4 (IPv4) represents each IP adresses 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 a 32 bit addresses?

2^96 times a many addresses are available

A computer program uses 3 bits to represent integers. When the program adds the decimal (base 10) number 5 and 3, the result is 0. Which of the following is the best explanation for the result.

An overflow error occured

Which of the following best describes a direct benefit in using redundant routing on the internet?

Redundancy often allows messages to be sent on the network even if some network devices or connections have failed.

Two computers are built by different manufacturers. One is running a Web server and the other is running a Web browser. Which of the following best describes the ability of the two computers to communicate with each other across the Internet?

The computers can communicate directly because Internet communication uses standard protocols.

In which of the following situations would it be most appropriate to choose lossy compression over lossless compression?

Storing music files on a smartphone in order to maximize the number of songs that can be stores

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? a. 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. b. The updated model is likely to decrease the runtime of the simulation because simulations that use older models tend to require more time to run than simulations that use newer models. c. The updated model is unlikely to decrease the runtime of the simulation because the simulation is computationally complex, regardless of the model used. d. The updated model is unlikely to provide any benefit because removing details from a model will compromise the accuracy of the simulation.

a. 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 following procedures are available for string manipulation. Procedure CallExplanationsubstring(str, start, end)Returns a substring of consecutive characters of str starting with the character at position start and ending with the character at position end. The first character of str is considered position 1. For example, substring("delivery", 3, 6) returns "live".concat(str1, str2)Returns a single string consisting of str1 followed by str2. For example, concat("key", "board") returns "keyboard".len(str)Returns the number of characters in str. For example, len("key") returns 3. A programmer wants to create a new string by removing the character in position n of the string oldStr. For example, if oldStr is "best" and n is 3, then the new string should be "bet". Assume that 1 < n < len(oldStr). Which of the following code segments can be used to create the desired new string and store it in newStr ? Select two answers. a. left ← substring(oldStr, 1, n - 1)right ← substring(oldStr, n + 1, len(oldStr))newStr ← concat(left, right) b. left ← substring(oldStr, 1, n + 1)right ← substring(oldStr, n - 1, len(oldStr))newStr ← concat(left, right) c. newStr ← substring(oldStr, 1, n - 1)newStr ← concat(newStr, substring(oldStr, n + 1, len(oldStr))) d. newStr ← substring(oldStr, n + 1, len(oldStr))newStr ← concat(newStr, substring(oldStr, 1, n - 1))

a. left ← substring(oldStr, 1, n - 1)right ← substring(oldStr, n + 1, len(oldStr))newStr ← concat(left, right) c. newStr ← substring(oldStr, 1, n - 1)newStr ← concat(newStr, substring(oldStr, n + 1, len(oldStr)))

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? a. 17 b. 14 c. 11 d. 4

b. 14

A sorted list of numbers contains 128 elements. Which of the following is closest to the maximum number of list elements that can be examined when performing a binary search for a value in the list? a. 2 b. 8 c. 64 d. 128

b. 8

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

b. 8

The procedure Draw (length, direction) is used to draw a line segment length units long in a given direction (left, right, up, or down), starting at the current cursor position. The cursor is then repositioned at the end of the line segment that was drawn. Consider the following program, where the cursor starts in the upper left corner of a grid of dots. The dots are spaced one unit apart. Draw (1, right) Draw (2, down) Draw (1, left) Draw (1, right) Draw (1, up) Draw (1, left) Which of the following represents the figure that is drawn by the program? A. Image with alt text: Choice A shows a three by three square grid of dots with line segments connecting certain dots. In choice A there are line segments in the first column connecting the first to second and second to third dots, and in all three rows connecting the first and second dots. B. Image with alt text: Choice B shows a three by three square grid of dots with line segments connecting certain dots. In choice B there are line segments in the second column connecting the first to second and second to third dots, and in all three rows connecting the first and second dots. C. Image with alt text: Choice C shows a three by three square grid of dots with line segments connecting certain dots. In choice C there are line segments in the second column connecting the first to second and second to third dots, in the first and third rows connecting the first and second dots, and in the second row connecting the second and third dots. D. a. A b. B c. C d. D

b. B

Ticket prices for a science museum are shown in the following table. Type of TicketGeneral Admission Cost(in dollars)Guided Tour Cost(in dollars)Regular (ages 13 and up)810Child (ages 12 and below)68 A programmer is creating an algorithm to display the cost of a ticket based on the information in the table. The programmer uses the integer variable age for the age of the ticket recipient. The Boolean variable includesTour is true when the ticket is for a guided tour and is false when the ticket is for general admission. Which of the following code segments correctly displays the cost of a ticket? A. cost ←← 6 IF ((age > 12) OR includesTour) { cost ←← cost + 2 } DISPLAY (cost) B. cost ←← 6 IF (age > 12) { cost ←← cost + 2 } IF (includesTour) { cost ←← cost + 2 } DISPLAY (cost) C. cost ←← 6 IF (age > 12) { IF (includesTour) { cost ←← cost + 2 } D. cost ←← 6 IF (age > 12) { cost ←← cost + 2 } ELSE { IF (includesTour) { cost ←← cost + 2 } } DISPLAY (cost) a. A b. B c. C d. D

b. B

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.

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

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.

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.

The figure below shows four grids, each containing a robot represented as a triangle. The robot cannot move to a black square or move beyond the edge of the grid. 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. Selected: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.

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.

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.

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.

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.

b. The elements of the list are not sorted.

Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. 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. Khalil does better on the midterm exam than on the final exam, so his original midterm and final exam scores are added to compute his total points. Josefina does better on the final exam than on the midterm exam, so her final exam score replaces her midterm exam score in the total points calculation. A programmer is writing a procedure to calculate a student's final grade in the course using the score replacement policy described. The student's exam scores are stored in the variables and . The procedure returns the larger of and . Which of the following could be used in the procedure to calculate a student's total points earned in the course and store the result in the variable ? a. adjustedTotal <--- Max (midtermExam, finalExam) b. adjustedTotal <--- Max (midtermExam, finalExam) + final Exam c. adjustedTotal <--- Max (midtermExam, finalExam) + midtermExam d. adjustedTotal <--- 2 * Max (midtermExam, finalExam)

b. adjustedTotal <--- Max (midtermExam, finalExam) + final Exam

Consider the following procedure. Procedure CallExplanationdrawLine(x1, y1, x2, y2)Draws a line segment on a coordinate grid with endpoints at coordinates (x1, y1) and (x2, y2) The drawLine procedure is to be used to draw the following figure on a coordinate grid. Let the value of the variable xVal be 6 and the value of the variable yVal be 5. Which of the following code segments can be used to draw the figure? a. drawLine(1, 5, xVal, yVal)drawline(1, 5, xVal, yVal + 2)drawline(1, 5, xVal, yVal + 2) b. drawLine(1, 5, xVal, yVal)drawline(1, 5, xVal, yVal + 2)drawline(1, 5, xVal, yVal - 2) c. drawLine(1, 5, xVal, yVal)drawline(1, 5, xVal + 2, yVal + 2)drawline(1, 5, xVal + 2, yVal - 2) d. drawLine(1, 5, xVal, yVal)drawline(1, 5, xVal + 2, yVal + 2)drawline(1, 5, xVal - 2, yVal - 2)

b. drawLine(1, 5, xVal, yVal)drawline(1, 5, xVal, yVal + 2)drawline(1, 5, xVal, yVal - 2)

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 a. 3 b. 4 c. 5 d. 7

c. 5

Which of the following best exemplifies the use of multifactor authentication to protect an online banking system? a. When a user resets a password for an online bank account, the user is required to enter the new password twice. b. When multiple people have a shared online bank account, they are each required to have their own unique username and password. c. After entering a password for an online bank account, a user must also enter a code that is sent to the user's phone via text message. d. An online bank requires users to change their account passwords multiple times per year without using the same password twice.

c. After entering a password for an online bank account, a user must also enter a code that is sent to the user's phone via text message.

What does ASCII stand for? a. Algorithmic Sequence of Computer Integrated Information b. All Standards Complete Initialization Interface c. American Standard Code for Information Interchange d. Aspiring Students Confused by Incoherent Incantations

c. American Standard Code for Information Interchange

Algorithm A Step 1: All students stand. Step 2: A randomly selected student writes his or her height on a card and is seated. Step 3: A randomly selected standing student adds his or her height to the value on the card, records the new value on the card, and is seated. The previous value on the card is erased. Step 4: Repeat step 3 until no students remain standing. Step 5: The sum on the card is divided by 32. The result is given to the teacher. Algorithm B Step 1: All students stand. Step 2: Each student is given a card. Each student writes his or her height on the card. Step 3: Standing students form random pairs at the same time. Each pair adds the numbers written on their cards and writes the result on one student's card; the other student is seated. The previous value on the card is erased. Step 4: Repeat step 3 until one student remains standing. Step 5: The sum on the last student's card is divided by 32. The result is given to the teacher. Which of the following statements is true? a. Algorithm A always calculates the correct average, but Algorithm B does not. b. Algorithm B always calculates the correct average, but Algorithm A does not. c. Both Algorithm A and Algorithm B always calculate the correct average. d. Neither Algorithm A nor Algorithm B calculates the correct average.

c. Both Algorithm A and Algorithm B always calculate the correct average.

The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the bottom right square of the grid and facing toward the top of the grid. The following programs are each intended to move the robot to the gray square. Program II uses the procedure GoalReached, which returns true if the robot is in the gray square and returns false otherwise. a. Program I correctly moves the robot to the gray square, but program II does not. b. Program II correctly moves the robot to the gray square, but program I does not. c. Both program I and program II correctly move the robot to the gray square. d. Neither program I nor program II correctly moves the robot to the gray square.

c. Both program I and program II correctly move the robot to the gray square.

Programs I and II below are each intended to calculate the sum of the integers from 1 to n. Assume that n is a positive integer (e.g., 1, 2, 3, ...). Which of the following best describes the behavior of the two programs? a. Program I displays the correct sum, but program II does not. b. Program II displays the correct sum, but program I does not. c. Both program I and program II display the correct sum. d. Neither program I nor program II displays the correct sum.

c. Both program I and program II display the correct sum.

The figure below shows a robot in a grid of squares. The robot is represented as a triangle, which is initially facing upward. The robot can move into a white or gray square but cannot move into a black region. Consider the procedure MoveAndTurn below. Which of the following code segments will move the robot to the gray square? A. , , Image with alt text: Choice A has three boxes in a column. In choice A the top box reads MoveAndTurn, then 1,2 in a rectangle. The middle box reads MoveAndTurn, then 3, 4 in a rectangle. The bottom box reads MoveAndTurn, then 0, 2 in a rectangle. B. , , Image with alt text: Choice B has three boxes in a column. In choice B the top box reads MoveAndTurn, then 2,1 in a rectangle. The middle box reads MoveAndTurn, then 4, 1 in a rectangle. The bottom box reads MoveAndTurn, then 2, 0 in a rectangle. C. , , Image with alt text: Choice C has three boxes in a column. In choice C the top box reads MoveAndTurn, then 2,1 in a rectangle. The middle box reads MoveAndTurn, then 4, 3 in a rectangle. The bottom box reads MoveAndTurn, then 2, 0 in a rectangle. D. , , Image with alt text: Choice D has three boxes in a column. In choice D the top box reads MoveAndTurn, then 3,1 in a rectangle. The middle box reads MoveAndTurn, then 5, 3 in a rectangle. The bottom box reads MoveAndTurn, then 3, 0 in a rectangle. a. A b. B c. C d. D

c. C

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? a. Lines 1 and 2 should be interchanged. b. Line 3 should be changed to REPEAT UNTIL (i ≥ 10). c. Lines 5 and 6 should be interchanged. d. No change is needed; the program works correctly.

c. Lines 5 and 6 should be interchanged.

Which of the following is true of lossy and lossless compression techniques? a. Lossless compression throws away unimportant details that a human being will likely be unable to detect. b. Lossy compression techniques are no longer commonly used. c. Lossless compression is fully reversible, meaning the original file can be recreated bit for bit. d. Lossy compression is only possible on files that are at least one gigabyte in size before compression.

c. Lossless compression is fully reversible, meaning the original file can be recreated bit for bit.

Consider the two programs below. Which of the following best compares the values displayed by programs A and B? a. Program A and program B display identical values. b. Program A and program B display the same values in different orders. c. Program A and program B display the same number of values, but the values differ. d. Program A and program B display a different number of values.

c. Program A and program B display the same number of values, but the values differ.

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.

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

An overflow error occurs when there aren't enough bits to represent a given number. Which of following would cause an overflow error to occur. (Choose all that apply.) a. Trying to represent 15 in 4 bits. Selected:b. Trying to represent 16 in 4 bits.This answer is correct. c. Trying to represent 32 in 5 bits d. Trying to represent 31 in 5 bits.

c. Trying to represent 32 in 5 bits

Mary is completing a project as part of a science class using materials she found online. Which of the following is MOST LIKELY to lead to legal consequences? a. Failing to publish her work under a Creative Commons license. b. Modifying a piece of open source software. c. Using images posted online by another student without permission or citation. d. Using open access research for which she does not acquire a license.

c. Using images posted online by another student without permission or citation.

The procedure below is intended to display the index in a list of unique names (nameList) where a particular name (targetName) is found. If targetName is not found in nameList, the code should display 0. Which of the following procedure calls can be used to demonstrate that the procedure does NOT work as intended? a. FindName (["Andrea", "Ben"], "Ben") b. FindName (["Andrea", "Ben"], "Diane") c. indName (["Andrea", "Ben", "Chris"], "Ben") d. FindName (["Andrea", "Chris", "Diane"], "Ben")

c. indName (["Andrea", "Ben", "Chris"], "Ben")

The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the center square and facing toward the top of the grid. The following code segment is used to move the robot in the grid. Which of the following code segments will move the robot from the center square along the same path as the code segment above?

count <-- 0 repeat 4 times { count <-- count +1 repeat count times ( Move_forward() ) Rotate_left()

A programmer wants to determine whether a score is within 10 points of a given target. For example, if the target is 50, then the scores 40, 44, 50, 58, and 60 are all within 10 points of the target, while 38 and 61 are not. Which of the following Boolean expressions will evaluate to true if and only if score is within 10 points of target ? a. (score ≤ target + 10) AND (target + 10 ≤ score) b. (target + 10 ≤ score) AND (score ≤ target - 10) c. (score ≤ target - 10) AND (score ≤ target + 10) d. (target - 10 ≤ score) AND (score ≤ target + 10)

d. (target - 10 ≤ score) AND (score ≤ target + 10)

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.

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

Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. Consider the code segment below. Which of the following changes will NOT affect the results when the code segment is executed? a. Changing line 3 to b <--- 10 b. Changing line 3 to a <--- b + 10 c. Changing line 7 to b <--- 20 d. Changing line 7 to a <---b + 20

d. Changing line 7 to a <---b + 20

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.

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.

Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. A programmer notices the following two procedures in a library. The procedures do similar, but not identical, things. Procedure returns the value . Procedure returns the value . Which of the following procedures is a generalization of the procedures described above? a. Procedure Add, open parenthesis n comma m, close parenthesis, which returns the value n + m b. Procedure Fourth, open parenthesis, n, close parenthesis , which returns the value n ^4 c. Procedure Polynomial, open parenthesis, c, close parenthesis, which returns the value n ^3 power plus n^2 d. Procedure Power, open parenthesis, n comma m, close parenthesis, which returns the value n ^ m power

d. Procedure Power, open parenthesis, n comma m, close parenthesis, which returns the value n ^ m power

Which of the following statements is true? a. Every problem can be solved with an algorithm for all possible inputs, in a reasonable amount of time, using a modern computer. b. Every problem can be solved with an algorithm for all possible inputs, but some will take more than 100 years, even with the fastest possible computer. c. Every problem can be solved with an algorithm for all possible inputs, but some of these algorithms have not been discovered yet. d. There exist problems that no algorithm will ever be able to solve for all possible inputs.

d. There exist problems that no algorithm will ever be able to solve for all possible inputs.

Which of the following is an example of a phishing attack? a. Loading malicious software onto a user's computer in order to secretly gain access to sensitive information b. Flooding a user's computer with e-mail requests in order to cause the computer to crash c. Gaining remote access to a user's computer in order to steal user IDs and passwords d. Using fraudulent e-mails in order to trick a user into voluntarily providing sensitive information

d. Using fraudulent e-mails in order to trick a user into voluntarily providing sensitive information

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? a. coin_flip = 1 b. flip_counter = 1 c. flip_counter = 2 d. heads_counter = 2

d. heads_counter = 2

A flowchart provides a way to visually represent an algorithm and uses the following building blocks. BlockExplanationOvalThe start or end of the algorithmRectangleOne or more processing steps, such as a statement that assigns a value to a variableDiamondA conditional or decision step, where execution proceeds to the side labeled true if the condition is true and to the side labeled false otherwiseParallelogramDisplays a message In the flowchart below, assume that j and k are assigned integer values. Which of the following initial values of j and k will cause the algorithm represented in the flowchart to result in an infinite loop? a. j = -5, k = 5 b. j = 0, k = 5 c. j = 5, k = 0 d. j = 5, k = -5

d. j = 5, k = -5

The following code segment is used to determine whether a customer is eligible for a discount on a movie ticket. 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

d. val1 = false, val2 = false

A color in a computing application is represented by an rGB triplet that describes the amount of red, green, and blue, respectively, used to create the desired color. A selection of colors and their corresponding RGB triplets are shown in the following table. Each value is represented in decimal (base 10). According to information in the table, what color is represented by the binary RGB triplet 11111111, 11111111, 11110000).

ivory


Set pelajaran terkait

Chapter 5 Developing the Research Plan

View Set

intro to religions: hinduism and buddhism

View Set

Learning System 2.0 Fundamentals

View Set

Imperialism/WWI/Russian Revolution

View Set

N415 The Child with Respiratory Dysfunction

View Set

Cloud, Virtualization, Wireless Security (Ch 10, 11)

View Set

Life Span Development: Chapter 3 Assignment

View Set

Chapter 28- Face and Neck Injuries

View Set