Font size
WorksheetsAPCSP- Final
Total questions: 25
Worksheet time: 21mins
for (var i = 10; i > 5; i--){
console.log ("p"); }
How many times will "p" be printed?
10
5
6
infinite loop
Based on the following, determine whether each expression is TRUE or FALSE
var score= 80;
(score != 90) && (score > 70)
True
False
What is an algorithm
Al Gore wasn't only a vice president, but he also mad some way cool jams too!
breaking down a task into steps which, when carried out, accomplish the main task
When a computer runs code through the CPU
a mathematical procedure designed to complete complex tasks fast
What 2 items below make your code easier to read and manage/edit later?
good variable names
testing your code often
write perfect code the first time
comments
What is more important to know when first starting a program?
what language to use
how much the program will sell for
what data the program needs and what it will do with the data
how long you have to finish the program
Determine what is printed by the following code.
values ⬅ [5, 6, 7, 0, 3, 3]
baz ⬅ 0
FOR EACH value IN values
{
if( value ≥ 7 )
{
baz ⬅ baz + 1
}
}
DISPLAY( baz )
1
0
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)
11
12
23
32
Determine what is printed by the following code.
numbers ⬅ [7, 4, 1, 6, 4, 11, 3]
baz ⬅ 0
FOR EACH value IN numbers
{
if( value < 3 )
{
baz ⬅ baz + 1
}
}
DISPLAY( baz )
0
1
none of the above
One data point that is stored in a list. It is a single part of a larger group.
Element
Index
List
A data structure that stores one or more similar types of values in a single value. A collection of individual values that are related.
Element
Index
List
Identifies a value’s unique position on a list. In SNAP & on the APCSP exam the first item is stored at index 1.
Element
Index
List
Performing the same operation on each item of the list, sequentially.
Traverse
Remove/Delete
Append
What is displayed from this code?
1,2,3,4,5
Nothing, it won't run
1, 2, 4, 8
1, 2, 4
A student wants to create an algorithm that can determine, given any program and program input, whether or not the program will go into an infinite loop for that input. The problem the student is attempting to solve is considered an undecidable problem. Which of the following is true?
It is possible to create an algorithm that will solve the problem for all programs and inputs, but the
algorithm can only be implemented in a low-level programming language.
It is possible to create an algorithm that will solve the problem for all programs and inputs, but the
algorithm requires simultaneous execution on multiple CPUs.
It is possible to create an algorithm that will solve the problem for all programs and inputs, but the
algorithm will not run in reasonable time.
It is not possible to create an algorithm that will solve the problem for all programs and inputs.
An algorithm with an efficiency rating of
would be considered
reasonable time
unreasonable time
If the length of the list is 100 times longer, the search will might on average only take 7-8 times longer to complete.
This is true using a:
linear search
binary search
If the length of the list is 100 times longer, the search will probably on average take 100 times longer to complete.
This is true using a:
linear search
binary search
The action of doing something over and over again.
Looping
Bugging
Programming
