AP Comp Sci Midterm

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

The figure below shows a circuit composed of two logic gates. The output of the circuit is true. false A OR true AND true Which of the following is a true statement about input A?

Input A must be true

A programmer wrote the code segment below to display the average of all the elements in a list called numbers. There is always at least one number in the list. The programmer wants to reduce the number of operations that are performed when the program is run. Which change will result in a correct program with a reduced number of operations performed?

Interchanging line 7 and line 8.

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 (74)

Consider the following program code. Which of the following best describes the result of running the program code? (uses i and sum)

Nothing is displayed; the program results in an infinite loop

Which of the following activities poses the greatest personal cybersecurity risk?

Reserving a hotel room by e-mailing a credit card number to a hotel

An algorithm has been developed to compute the sum of all the elements in a list of integers. Which of the following programming structures must be added to the existing algorithm so that the new algorithm computes the sum of only the even integers in the list?

Selection

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?

Sorting data

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?

Technology companies can set research and development goals based on anticipated processing speeds.

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?

The conclusion is incorrect; using the test case [0, 1, 4, 5] is not sufficient to conclude the program is correct.

A certain computer game is played between a human player and a computer-controlled player. Every time the computer-controlled player has a turn, the game runs slowly because the computer evaluates all potential moves and selects the best one. Which of the following best describes the possibility of improving the running speed of the game?

The game's running speed might be improved by using a process that finds approximate solutions every time the computer-controlled player has a turn.

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?

The number of movies purchased by an individual subscriber for a particular month

In the procedure Mystery below, the parameter number is a positive integer. Which of the following best describes the result of running the procedure Mystery?

The procedure returns true when the initial value of number is even, and it otherwise returns false.

A program is expressed in a programming language. Which of the following is true of the program?

The program can also be expressed as binary code, but will be more easily understood by humans when expressed in a higher-level programming language.

Consider the following program, which is intended to display the number of times a number target appears in a list. Which of the following best describes the behavior of the program?

The program correctly displays the number of times target appears in the list.

A new bank plans to make customer convenience a priority by minimizing the amount of time a customer waits in line. The bank is considering two options: a single line where the customer at the front waits for the next available teller, or separate lines for each teller. The bank decides to use a computer simulation of these two options to determine the average wait time for customers. Which of the following is NOT true about the bank's plan?

The simulation will not produce usable results because actual customer data isn't available.

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?

The song was saved using fewer bits per second than the original song

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?

To determine the topics that many users are posting about

ASCII characters can also be represented by hexadecimal numbers. According to ASCII character encoding, which of the following letters is represented by the hexadecimal (base 16) number 56?

V (86)

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?

Web sites that are not visited frequently might no longer be accessible to users.

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?

Which items listed in the database are not currently in the store

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

about.example.com

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?

an overflow error occurred

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?

head_counter = 2

Which of the following replacements for <MISSING CONDITION> will result in an infinite loop?

j = 6

The 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?

(num MOD 2) = 1

Consider the following code segment, which uses the variables r, s, and t. r ← 1 s ← 2 t ← 3 r ← s s ← t DISPLAY (r) DISPLAY (s) What is displayed as a result of running the code segment?

2 3

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?

2 times as many items can be uniquely identified.

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?

2^(32) Times as many values can be represented

The figure below represents a network of physically linked computers labeled A through G. A line between two computers indicates that the computers can communicate directly with each other. Any information sent between two computers that are not directly connected must go through at least one other computer. For example, information can be sent directly between computers A and B, but information sent between computers A and C must go through other computers. What is the minimum number of connections that must be broken or removed in the network before computer E can no longer communicate with computer F?

3

In the program below, y is a positive integer (e.g., 1, 2, 3, ...)What is the value of result after running the program?

3y

A flowchart is a way to visually represent an algorithm. The flowchart below uses the following building blocks. Oval, rectangle, diamond, parallelogram. What is displayed as a result of executing the algorithm in the flowchart?

5

The following question uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the bottom left square of the grid and facing right. Consider the following code segment, which moves the robot in the grid. Which of the following shows the location of the robot after running the code segment?

A (middle square facing down)

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

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

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?

B (backwards E)

If the variables onTime and absent both have the value false, what is displayed as a result of running the code segment?

Better late than never.

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?

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?

C (MaT: 2,1 MaT: 4,3 MaT: 2,0)

Which of the following statements describes a limitation of using a computer simulation to model a real-world object or system?

Computer simulations usually make some simplifying assumptions about the real-world object or system being modeled.

Digital images are often represented by the red, green, and blue values (an RGB triplet) of each individual pixel in the image. A photographer is manipulating a digital image and overwriting the original image. Which of the following describes a lossless transformation of the digital image?

Creating the negative of an image by creating a new RGB triplet for each pixel in which each value is calculated by subtracting the original value from 255. The negative of an image is reversed from the original;light areas appear dark, and colors are reversed.

The program segment below is intended to move a robot in a grid to a gray square. The program segment uses the procedure GoalReached, which evaluates to true if the robot is in the gray square and evaluates to false otherwise. The robot in each grid is represented as a triangle and is initially facing left. The robot can move into a white or gray square but cannot move into a black region. For which of the following grids does the program NOT correctly move the robot to the gray square?

D

Consider the following numbers. Binary 1100 Decimal 11 Hexadecimal D Which of the following lists the numbers in order from least to greatest?

Decimal 11, Binary 1100, Hexadecimal D

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?

Do the movement patterns of the animal vary according to the weather?

A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of goats and sheep throughout the text. Consider the programmer's goal of changing all occurrences of "goats" to "sheep" and all occurrences of "sheep" to "goats." The programmer will use the fact that the word "foxes" does not appear anywhere in the original text. Which of the following algorithms can be used to accomplish the programmer's goal?

First, change all occurrences of "goats" to "foxes." Then, change all occurrences of "sheep" to "goats." Last, change all occurrences of "foxes" to "sheep."

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?

How many programming statements the program contains

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?

How many states have a higher percentage of female computer science majors than male computer science majors attending college in that state?

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

I, II, and III

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

II and III only

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 ?

newList ← Combine (list1, list2) newList ← Sort (newList) newList ← RemoveDuplicates (newList)

A code segment will be used to swap the values of the variables a and b using the temporary variable temp. Which of the following code segments correctly swaps the values of a and b ?

temp <--- a a <--- b b <--- temp

The diagram below shows a circuit composed of two logic gates labeled OR and AND. Each gate takes two inputs and produces a single output. A B OR C AND output If the inputs A and C are both true, which of the following best describes the output of the AND gate?

the output will be true no matter what the value of B is


Set pelajaran terkait

Security+ Assessment Exam 2 (DG)

View Set

FEMA IS-0700.b: An introduction to NIMS

View Set

Interactions Between Humans and the Environment 8.3

View Set

California Real Estate Principles - Chapter 5 - Encumbrances

View Set

IT 150: Pneumatic Actuators and Control Valves

View Set

Trends in 21st Century - Long Quiz

View Set

Social media marketing hub spot exam

View Set

AUTONOMIC NERVOUS SYSTEM TCC PARAMEDIC

View Set

Study Guide, Dorian Gray, Ch. 1-10 (I-X)

View Set