100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

AP CSP Semester 1 Exam with Complete Solutions

Rating
-
Sold
1
Pages
33
Grade
A+
Uploaded on
23-12-2022
Written in
2022/2023

Consider the following code segment. Which of the following best describes the behavior of the code segment? - ANSWER-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. In the following procedure, assume that the parameter x is an integer. Which of the following best describes the behavior of the procedure? - ANSWER-It displays true if x is negative and displays nothing otherwise. 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? - ANSWER-Collaboration that includes diverse backgrounds and perspectives can eliminate the need for software testing. Central High School keeps a database of information about each student, including the numeric variables numberOfAbsences and gradePointAverage. The expression below is used to determine whether a student is eligible to receive an academic award. (numberOfAbsences ≤ 5) AND (gradePointAverage 3.5) Which of the following pairs of values indicates that a student is eligible to receive an academic award? - ANSWER-numberOfAbsences = 5, gradePointAverage = 3.8 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? Each group member's list of food allergies or dietary restrictions Alejandra's geographic location The usernames of the people on Brandon and Cynthia's contact lists - ANSWER-I and II only 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? Brandon's contact list Information about which restaurants Brandon and Cynthia have visited in the past Information about which food allergies and dietary restrictions can be accommodated at different restaurants near Alejandra - ANSWER-III only A programmer wrote the program below. The program uses a list of numbers called numList. The program is intended to display the sum of the numbers in the list. In order to test the program, the programmer initializes numList to [0, 1, 4, 5]. The program displays 10, and the programmer concludes that the program works as intended. Which of the following is true? - ANSWER-The conclusion is incorrect; using the test case [0, 1, 4, 5] is not sufficient to conclude the program is correct. D The upgraded system uses a directory containing additional information not supplied by the customer. The directory is used to help direct calls effectively. Which of the following is LEAST likely to be included in the directory? - ANSWER-A list of computers the company owns and the computers' corresponding IP addresses To direct a call to the appropriate destination, which of the following input data is needed by the upgraded system that was NOT needed by the original system? Audio signal of the customer's voice The customer's keypad selection The customer's phone number - ANSWER-I only 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? - ANSWER-Prints all positive odd integers that are less than or equal to max. 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? - ANSWER-Displays the value of (x + y) / x. The value of the parameter x must not be 0. 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? - ANSWER-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 The following procedure is intended to return the number of times the value val appears in the list myList. The procedure does not work as intended. Which of the following changes can be made so that the procedure will work as intended? - ANSWER-Moving the statement in line 5 so that it appears between lines 2 and 3 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? - ANSWER-Interchanging lines 3 and 7 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? - ANSWER-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 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? - ANSWER-The code segment iterates through myList, comparing each element to all subsequent elements in the list. The following code segment is intended to set max equal to the maximum value among the integer variables x, y, and z. The code segment does not work as intended in all cases. Which of the following initial values for x, y, and z can be used to show that the code segment does not work as intended? - ANSWER-x = 3, y = 2, z = 1 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? - ANSWER-The cost of a food item currently available for order 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? - ANSWER-[-1, 0, 1] A homework assignment consists of 10 questions. The assignment is graded as follows. Number of Correct Answers Grade9-10check plus7-8checkUnder 7check 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? Select two answers. - ANSWER-8, 6 Which of the following is a true statement about program documentation? - ANSWER-Program documentation is useful during initial program development and also when modifications are made to existing programs. Two grids are shown below. Each grid contains a robot represented as a triangle. Both robots are initially facing left. Each robot can move into a white or gray square, but cannot move into a black region. For each grid, the program below is intended to move the robot to the gray square. The program uses the procedure Goal_Reached ( ), which evaluates to true if the robot is in the gray square and evaluates to false otherwise. For which of the grids does the program correctly move the robot to the gray square? - ANSWER-Grid I only 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? - ANSWER-Users can provide feedback that can be used to incorporate a variety of perspectives into the software. 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? - ANSWER-FindName (["Andrea", "Ben", "Chris"], "Ben") A programmer is writing a program that is intended to be able to process large amounts of data. Which of the following considerations is LEAST likely to affect the ability of the program to process larger data sets? - ANSWER-How many programming statements the program contains 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? - ANSWER-An overflow error will occur because 4 bits is not large enough to represent 29, the sum of 14 and 15. Which of the following is an advantage of a lossless compression algorithm over a lossy compression algorithm? - ANSWER-A lossless compression algorithm can guarantee reconstruction of original data, while a lossy compression algorithm cannot. A digital photo file contains data representing the level of red, green, and blue for each pixel in the photo. The file also contains metadata that describes the date and geographic location where the photo was taken. For which of the following goals would analyzing the metadata be more appropriate than analyzing the data? - ANSWER-Determining the likelihood that the photo was taken at a particular public event Biologists often attach tracking collars to wild animals. For each animal, the following geolocation data is collected at frequent intervals. The time The date The location of the animal Which of the following questions about a particular animal could NOT be answered using only the data collected from the tracking collars? - ANSWER-Do the movement patterns of the animal vary according to the weather? An online store uses 6-bit binary sequences to identify each unique item for sale. The store plans to increase the number of items it sells and is considering using 7-bit binary sequences. Which of the following best describes the result of using 7-bit sequences instead of 6-bit sequences? - ANSWER-2 times as many items can be uniquely identified. 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? - ANSWER-Four bits are enough to store the eight directions. A large spreadsheet contains the following information about the books at a bookstore. A sample portion of the spreadsheet is shown below. 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 evaluates to false otherwise? - ANSWER-(genre = "mystery") AND ((1 ≤ num) AND (cost 10.00)) A cable television company stores information about movie purchases made by subscribers. Each day, the following information is summarized and stored in a publicly available database. The day and date each movie was purchased The title of each movie purchased The cities where subscribers purchased each movie The number of times each movie was purchased by subscribers in a given city A sample portion of the database is shown below. The database is sorted by date and movie title. Which of the following CANNOT be determined using only the information in the database? - ANSWER-The number of movies purchased by an individual subscriber for a particular month 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? - ANSWER-Students who have the same name may be confused with each other. 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? - ANSWER-Different counties may organize data in different ways. 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. - ANSWER-Users might enter abbreviations for the names of cities. Users might misspell the name of the city. 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? - ANSWER-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. Two lists, list1 and list2, contain the names of books found in two different collections. A librarian wants to create newList, which will contain the names of all books found in either list, in alphabetical order, with duplicate entries removed. For example, if list1 contains ["Macbeth", "Frankenstein", "Jane Eyre"] and list2 contains ["Frankenstein", "Dracula", "Macbeth", "Hamlet"], then newList will contain ["Dracula", "Frankenstein", "Hamlet", "Jane Eyre", "Macbeth"]. The following procedures are available to create newList. Which of the following code segments will correctly create newList ? - ANSWER-newList ← Combine (list1, list2) newList ← Sort (newList) newList ← RemoveDuplicates (newList) 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? - ANSWER-Compressing the file using a lossless compression algorithm before uploading it A certain social media Web site allows users to post messages and to comment on other messages that have been posted. When a user posts a message, the message itself is considered data. In addition to the data, the site stores the following metadata. The time the message was posted The name of the user who posted the message The names of any users who comment on the message and the times the comments were made For which of the following goals would it be more useful to analyze the data instead of the metadata? - ANSWER-To determine the topics that many users are posting about A large data set contains information about all students majoring in computer science in colleges across the United States. The data set contains the following information about each student. The student's gender The state in which the student attends college The student's grade point average on a 4.0 scale Which of the following questions could be answered by analyzing only information in the data set? - ANSWER-How many states have a higher percentage of female computer science majors than male computer science majors attending college in that state? Which of the following is a true statement about data compression? - ANSWER-There are trade-offs involved in choosing a compression technique for storing and transmitting data. 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? - ANSWER-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 Which of the following are true statements about the data that can be represented using binary sequences? Binary sequences can be used to represent strings of characters. Binary sequences can be used to represent colors. Binary sequences can be used to represent audio recordings. - ANSWER-I, II, and III 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? - ANSWER-Average ticket price 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? - ANSWER-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. Historically, it has been observed that computer processing speeds tend to double every two years. Which of the following best describes how technology companies can use this observation for planning purposes? - ANSWER-Technology companies can set research and development goals based on anticipated processing speeds. A retailer that sells footwear maintains a single database containing records with the following information about each item for sale in the retailer's store. Item identification number Footwear type (sneakers, boots, sandals, etc.) Selling price (in dollars) Size Color Quantity available Using only the database, which of the following can be determined? - ANSWER-Which items listed in the database are not currently in the store 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? - ANSWER-The number of bicycles the car passed on a particular day 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? Do students who enjoy the subject material tend to spend more time on homework each night than the other students do? Do students who spend more time on homework each night tend to spend less time studying for tests than the other students do? Do students who spend more time studying for tests tend to earn higher grades in the class than the other students do? - ANSWER-I and II When a cellular telephone user places a call, the carrier transmits the caller's voice as well as the voice of the person who is called. The encoded voices are the data of the call. In addition to transmitting the data, the carrier also stores metadata. The metadata of the call include information such as the time the call is placed and the phone numbers of both participants. For which of the following goals would it be more useful to computationally analyze the metadata instead of the data? To determine if a caller frequently uses a specific word To estimate the number of phone calls that will be placed next Monday between 10:30 A.M. and noon. To generate a list of criminal suspects when given the telephone number of a known criminal - ANSWER-II and III only A large spreadsheet contains information about the photographs in a museum's collection. A sample portion of the spreadsheet is shown below. Which of the following sequences of steps can be used to identify the desired entry? Select two answers. - ANSWER-Filter by photographer, then filter by year, then sort by year Sort by year, then filter by year, then filter by photographer Each student that enrolls at a school is assigned a unique ID number, which is stored as a binary number. The ID numbers increase sequentially by 1 with each newly enrolled student. If the ID number assigned to the last student who enrolled was the binary number , what binary number will be assigned to the next student who enrolls? - ANSWER- 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? - ANSWER-What is the cost of a certain electronics product? A large spreadsheet contains information about the schedule for a college radio station. A sample portion of the spreadsheet is shown below. A student wants to count the number of shows that meet both of the following criteria. Is a talk show Is on Saturday or Sunday 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? - ANSWER-(genre = "talk") AND ((day = "Saturday") OR (day = "Sunday")) An Internet service provider (ISP) is considering an update to its servers that would save copies of the Web pages most frequently visited by each user. Which of the following is LEAST likely to occur as a result of the update? - ANSWER-Web sites that are not visited frequently might no longer be accessible to users. Computers are often used to search through large sets of data to find useful patterns in the data. Which of the following tasks is NOT an example where searching for patterns is needed to produce useful information? - ANSWER-A high school analyzing student grades to identify the students with the top ten highest grade point averages A student is recording a song on her computer. When the recording is finished, she saves a copy on her computer. The student notices that the saved copy is of lower sound quality than the original recording. Which of the following could be a possible explanation for the difference in sound quality? - ANSWER-The song was saved using fewer bits per second than the original song. The table below shows the time a computer system takes to complete a specified task on the customer data of different-sized companies. Based on the information in the table, which of the following tasks is likely to take the longest amount of time when scaled up for a very large company of approximately 100,000 customers? - ANSWER-Sorting data 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? - ANSWER-Lossy compression of an image file generally provides a greater reduction in transmission time than lossless compression does. A wildlife preserve is developing an interactive exhibit for its guests. The exhibit is intended to allow guests to select the name of an animal on a touch screen and display various facts about the selected animal. 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? - ANSWER-Both databases are needed. Each database can be searched by animal name to find all information to be displayed. Some programming languages use constants, which are variables that are initialized at the beginning of a program and never changed. Which of the following are good uses for a constant? I. To represent the mathematical value π (pi) as 3.14 II. To represent the current score in a game III. To represent a known value such as the number of days in a week - ANSWER-I and III only A computer program uses 3 bits to represent integers. When the program adds the decimal (base 10) numbers 5 and 3, the result is 0. Which of the following is the best explanation for the result? - ANSWER-An overflow error occurred. 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 planning 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? - ANSWER-2^32 times as many values can be represented. Which of the following can be represented by a single binary digit? Select two answers. - ANSWER-The remainder when dividing a whole number by 2 The value of a Boolean variable 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? - ANSWER-II only 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 ? - ANSWER-Subtract num1 from num2 and store the result in the variable diff. Step 2: Take the absolute value of diff and display the result. 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? - ANSWER-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? - ANSWER-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 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? - ANSWER-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. 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? - ANSWER-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. Which of the following algorithms display all integers between 1 and 20, inclusive, that are not divisible by 3 ? Select two answers. - ANSWER-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. 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. 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? - ANSWER-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. 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 ? Select two answers. - ANSWER-IF(score 100) { bonus ←← score * 10 } ELSE { IF(score ≥ 50) { bonus ←← score } ELSE { bonus ←← 0 } } IF(score 50) { bonus ←← 0 } ELSE { IF(score 100) { bonus ←← score * 10 } ELSE { bonus ←← score } } Which of the following is a benefit of using a list as a data abstraction in a program? - ANSWER-Lists often allow their size to be easily updated to hold as many data values as needed. 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? - ANSWER-Keeping the numeric values in a list makes it easier to apply the same computation to every data element. Which of the following is a benefit of using a simulation instead of an experiment to make a prediction? Select two answers. - ANSWER-A simulation allows investigation of a phenomenon without the real-world limitations on time, safety, or budget. A simulation can be used to model real-world events that are impractical for experiments. Which of the following are benefits of procedural abstraction? Select two answers. - ANSWER-Procedural abstraction makes it easier for people to read computer programs. Procedural abstraction provides an opportunity to give a name to a block of code that describes the purpose of the code block. Which of the following are benefits of using well-named variables in a computer program? Select two answers. - ANSWER-The program will be easier for people to read. The program will be easier to modify in the future. 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? - ANSWER-8 A sorted list of numbers contains 500 elements. Which of the following is closest to the maximum number of list elements that will be examined when performing a binary search for a value in the list? - ANSWER-10 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? - ANSWER-15 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? - ANSWER-The value of x is approximately equal to the value of y. 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? - ANSWER-There is no possible algorithm that can be used to solve all instances of the problem. Consider the following code segment. What are the contents of yourList after the code segment is executed? - ANSWER-[10, 30, 50, 70] A list of numbers has n elements, indexed from 1 to n. The following algorithm is intended to display the number of elements in the list that have a value greater than 100. The algorithm uses the variables count and position. Steps 3 and 4 are missing. Step 1:Set count to 0 and position to 1.Step 2:If the value of the element at index position is greater than 100, increase the value of count by 1.Step 3:(missing step) Step 4:(missing step) Step 5:Display the value of count. Which of the following could be used to replace steps 3 and 4 so that the algorithm works as intended? - ANSWER-Step 3: Increase the value of position by 1

Show more Read less
Institution
AP CSP Semester 1
Course
AP CSP Semester 1

Content preview

AP CSP Semester 1 Exam with Complete Solutions
Consider the following code segment.
Which of the following best describes the behavior of the code segment? - ANSWER-
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.
In the following procedure, assume that the parameter x is an integer.
Which of the following best describes the behavior of the procedure? - ANSWER-It displays true if x is negative and displays nothing otherwise.
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? - ANSWER-
Collaboration that includes diverse backgrounds and perspectives can eliminate the need for software testing.
Central High School keeps a database of information about each student, including the numeric variables numberOfAbsences and gradePointAverage. The expression below is used to determine whether a student is eligible to receive an academic award.
(numberOfAbsences ≤ 5) AND (gradePointAverage > 3.5)
Which of the following pairs of values indicates that a student is eligible to receive an academic award? - ANSWER-numberOfAbsences = 5, gradePointAverage = 3.8
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?
Each group member's list of food allergies or dietary restrictions
Alejandra's geographic location
The usernames of the people on Brandon and Cynthia's contact lists - ANSWER-I and II
only
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?
Brandon's contact list
Information about which restaurants Brandon and Cynthia have visited in the past
Information about which food allergies and dietary restrictions can be accommodated at different restaurants near Alejandra - ANSWER-III only
A programmer wrote the program below. The program uses a list of numbers called numList. The program is intended to display the sum of the numbers in the list.
In order to test the program, the programmer initializes numList to [0, 1, 4, 5]. The program displays 10, and the programmer concludes that the program works as intended.
Which of the following is true? - ANSWER-The conclusion is incorrect; using the test case [0, 1, 4, 5] is not sufficient to conclude the program is correct.
D
The upgraded system uses a directory containing additional information not supplied by the customer. The directory is used to help direct calls effectively. Which of the following
is LEAST likely to be included in the directory? - ANSWER-A list of computers the company owns and the computers' corresponding IP addresses
To direct a call to the appropriate destination, which of the following input data is needed by the upgraded system that was NOT needed by the original system?
Audio signal of the customer's voice
The customer's keypad selection
The customer's phone number - ANSWER-I only
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? - ANSWER-Prints all positive odd integers that are less than or equal to max.
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? - ANSWER-Displays the value of (x + y) / x. The value of the parameter x must not be 0.
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? - ANSWER-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
The following procedure is intended to return the number of times the value val appears in the list myList. The procedure does not work as intended.
Which of the following changes can be made so that the procedure will work as intended? - ANSWER-Moving the statement in line 5 so that it appears between lines 2 and 3
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? - ANSWER-Interchanging lines 3 and 7 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? - ANSWER-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 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? - ANSWER-The code segment iterates through myList, comparing each element to all subsequent elements in the list.
The following code segment is intended to set max equal to the maximum value among the integer variables x, y, and z. The code segment does not work as intended in all cases.
Which of the following initial values for x, y, and z can be used to show that the code segment does not work as intended? - ANSWER-x = 3, y = 2, z = 1
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? - ANSWER-The cost of a food item currently available for order
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? - ANSWER-[-1, 0, 1]
A homework assignment consists of 10 questions. The assignment is graded as follows.

Written for

Institution
AP CSP Semester 1
Course
AP CSP Semester 1

Document information

Uploaded on
December 23, 2022
Number of pages
33
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

CA$18.93
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached


Also available in package deal

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
LUCKYSTAR2022 West Virginia University
Follow You need to be logged in order to follow users or courses
Sold
910
Member since
4 year
Number of followers
724
Documents
9620
Last sold
1 week ago
LUCKYSTAR2022

Hi there well come to luckystar2022. Here you will find guaranteed quality solution for Nursing and any other Accademic related notes, exams, study guides, cases and many more. 100% value for your time and money. GOOD LUCK

3.5

156 reviews

5
62
4
26
3
25
2
8
1
35

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions