AP Comp Sci final
Consider the following programs. Which of the following best compares the values displayed by programs A and B?
Programs A and B have identical values in the same order
sequencing
Putting steps in an order
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?
15
Data Bias
the practice of obtaining input or information from a large number of people via the Internet.
Traversal
the process of accessing each item in a list one at a time
Argument
the value passed to the parameter
The code fragment below is intended to display "odd" if the positive number num is odd.If <Missing condition>display "odd"Which of the following can be used to replace <MISSING CONDITION> so that the code fragment will work asintended?
(D) (num MOD 2) = 1(remember that Mod is divide and the answer is the remainder)
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?
10
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?
8
Byte
8 bits
Bit
A contraction of "Binary Digit"; the single unit of information in a computer, typically represented as a 0 or 1
Return
used to return the flow of control to the point where the procedure (also known as a function) was called and to return the value of expression.
Binary
A way of representing information using only two options.
reasonable time
Algorithms with a polynomial efficiency or lower (constant, linear, square, cube, etc.) are said to run in a reasonable amount of time.
Unreasonable time
Algorithms with exponential or factorial efficiencies are examples of algorithms that run in an unreasonable amount of time.
List
An ordered collection of elements
API
Application Programming Interface - specifications for how functions in a library behave and can be used
The variable isOpen is to be used to indicate whether or not a store is currently open. Which of the following is the most appropriate data type for isOpen?
Boolean
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?
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.
Comment
Form of a program documentation written into the program to be read by people and which do not affect how a program runs
Selection
Deciding which steps to do next
Overflow Error
Error from attempting to represent a number that is too large.
Round-off Error
Error from attempting to represent a number that is too precise. The value is rounded.
Debugging
Finding and fixing problems in your algorithm or program.
The cost of a customer's electricity bill is based on the number of units of electricity the customer uses.For the first 25 units of electricity, the cost is $5 per unit.For units of electricity after the first 25, the cost is $7 per unit.Which of the following code segments correctly sets the value of the variable cost to the cost, in dollars, of using numUnits units of electricity?
If (numUnits < or = 25)[cost<--numUnits * 5]Else[cost<--25 7 + (numUnits - 25) 7]
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?
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.
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?
MoveandTurn [2,1] MoveandTurn [4,3] MoveandTurn [2,0]
The variable age is to be used to represent a person's age, in years. Which of the following is the most appropriate data type for age?
Number
User Interface
The inputs and outputs that allow a user to interact with a piece of software. User interfaces can include a variety of forms such as buttons, menus, images, text, and graphics.
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.
Index
a common method for referencing the elements in a list or string using numbers
Algorithm
a finite set of instructions that accomplish a task.
problem
a general description of a task that can (or cannot) be solved with an algorithm
Library
a group of functions (procedures) that may be used in creating new programs
Variable
a named reference to a value that can be used repeatedly throughout a program.
Correlation
a relationship between two pieces of data, typically referring to the amount that one varies in relation to the other.
Iteration
a repetitive portion of an algorithm which repeats a specified number of times or until a given condition is met.
Parameter
a variable in a function definition. Used as a placeholder for values that will be passed through the function.
Documentation
a written description of how a command or piece of code works or was developed.
Element
an individual value in a list that is assigned a unique index
String
an ordered sequence of characters.
Output
any data that are sent from a program to a device. Can come in a variety of forms, such as tactile interaction, audio, visuals, or text.
Data filtering
choosing a smaller subset of a data set to use for analysis, for example by eliminating / keeping only certain rows in a table
Input
data that are sent to a computer for processing by a program. Can come in a variety of forms, such as tactile interaction, audio, visuals, or text.
Data Abstraction
manage complexity in programs by giving a collection of data a name without referencing the specific details of the representation.
infinite loop
occurs when the ending condition will never evaluate to true.