Font size
WorksheetsUnit 10: Algorithms (APCSP '25-'26 code.org)
Total questions: 85
Worksheet time: 1hrs 18mins
This is known as a precise sequence of instructions for processes that can be executed by a computer and are implemented using programming languages.
Function
Parameter
Algorithm
Command
Which of the following is FALSE regarding algorithms?
Option 1: Different algorithms can be developed to solve the same problem
Option 2: Different code can never be written to implement the same algorithm
Both Option 1 and 2 are true
Both Option 1 and 2 are false
Every algorithm can be constructed on using:
Sequencing
Selection
Iteration
Questions
When your programming is achieving some desired outcome while minimizing wasted effort or resources, we would say that its:
Top Notch
Comparable
Efficient
Problematic
Looking at Lines 3 and 5 above, the "IF" statements in these particular parts of the algorithm are constructed with:
Selection
Iteration
Sequencing
Placing Lines 1-9 of your algorithm in a particular order shows which of the following is important?
Sequencing
Selection
Iteration
Looking at the image above, looping (through iteration) can be seen in which of the following lines of this algorithm?
Line 2
Line 7
Line 3
Line 9
The ordered steps in a program.
Sequence
If...Then...Else
Conditional
Value
________________ is a sequence of instructions (or algorithm) written in a language or code that a computer can understand and put into action. Must be accurate to be correct.
Procedure
Algorithm
Program
Loop/ Repeat
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.
PROCEDURE MoveTriangle (numMoves, numTurns)Which of the following instructions will get the red triangle to the gray square?
{
REPEAT numMoves TIMES
{
MOVE_FORWARD()
}
REPEAT numTurns TIMES
{
TURN_RIGHT()
}
}
MoveTriangle (1, 1) MoveTriangle (1, 1) MoveTriangle (3, 1) MoveTriangle (3, 0)
MoveTriangle (4, 1)
MoveTriangle (4, 0)
MoveTriangle (1, 1)
MoveTriangle (1, 3)
MoveTriangle (3, 1)
MoveTriangle (3, 0)
MoveTriangle (1, 1)
MoveTriangle (1, 3)
MoveTriangle (3, 3)
MoveTriangle (3, 0)
Writing a for-loop in Javascript is an example of what coding principle?
sequencing
sorting
iteration
selection
rotation
Writing an if-else statement in Javascript is an example of what coding principle?
sequencing
sorting
iteration
selection
rotation
An algorithm with an efficiency rating of
would be considered
reasonable time
unreasonable time
An algorithm with an efficiency rating of
would be considered
reasonable time
unreasonable time
A BINARY SEARCH looks for a certain name in a list of sixteen names. What is the most possible number of places it will have to check?
1
2
4
8
16
A LINEAR SEARCH looks for a certain name in a list of sixteen names. What is the most possible number of places it will have to check?
1
16
4
15
8
A BINARY SEARCH looks through a list named studentList finds an what it was searching for in the first spot it looked. Where was it?
at index 0
at index studentList.length / 2
at index studentList.length
A LINEAR SEARCH looks through a list named studentList finds an what it was searching for in the first spot it looked. Where was it?
at index 0
at index studentList.length/2
at index studentList.length
A finite list of instructions to solve a problem is called
an algorithm
a program
the solution
the answer
the code
If 7 people wait in line for the drinking fountain there would be ____ different orders.
7
49
14
5040
5 million
When working with 3 letters of the alphabet, they can be rearranged in _____ different orders.
3
5
6
9
27
To calculate the different orders that you could visit 10 cities using your calculator you would type:
10*10
10^10
10!
10+10
log 10
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
2 students write code that works to solve a problem in JavaScript.
Both students' code works.
What is the most significant difference that could still exist between the 2 students' code?
style
comments
variable names
efficiency
length of code
All problems can be solved using an algorithm.
TRUE
FALSE
Which of these, would work the fastest to find the number 10 in the list below?
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
linear search
perimeter search
straight search
binary search
split seach
Which of these, would work the fastest to find the number 7 in the list below?
[ 3, 7, 8, 15, 2, 4, 9, 10, 6, 5, 11, 1, 12, 13 ]
linear search
perimeter search
straight search
binary search
split seach
Which of these, given a list with 100 elements would look at index 50 first, and the decide to look at index 25 or index 75 next?
linear search
perimeter search
straight search
binary search
split seach
Which of these, given a list with 100 elements would look at index 0, then index 1, then index 2 ....
linear search
perimeter search
straight search
binary search
split seach
Using an "if" in your code is referred to in APCSP as:
iteration
selection
sequencing
sorting
prioritizing
Using a loop in your code is referred to in APCSP as:
iteration
selection
sequencing
sorting
prioritizing
Getting your code to execute commands in the correct order is called:
iteration
selection
sequencing
sorting
prioritizing
Finite means:
having a countable amount
being picky
completing a program
terminating your code
finishing an algorithm
A step by step process to solve a problem is called:
problem solving
an algorithm
code
a program
instructions
In JavaScript you would implement code ITERATION by:
(CHOOSE ALL CORRECT ANSWERS)
writing a for-loop
writing a while loop
making a list
writing an if statement
writing an if-else statement
In JavaScript you would implement code SELECTION by:
(CHOOSE ALL CORRECT ANSWERS)
writing a for-loop
writing a while loop
making a list
writing an if statement
writing an if-else statement
If it is AFTER 7am, what do you need to do?
Take the bus
Take the subway
Check the time
Leave home
You are at the yellow arrow, pointing in the direction indicated. How would you move to fill in the 2 black squares?
Straight, Turn right, Straight x 1, Fill Square, Straight x 2, Turn left, Straight x 1, Fill Square
Straight x 2, Turn right, Straight x 1, Fill Square, Straight x 2, Turn left, Straight x 1, Fill Square
Straight x 2, Turn right, Straight x 1, Fill Square, Straight x 2, Turn right, Straight x 1, Fill Square
Straight x 2, Turn right, Straight x 1, Fill Square, Straight x 2, Turn left, Straight x 2, Fill Square
What must be true before performing a binary search?
The elements must be sorted.
It can only contain binary values.
The elements must be some sort of number (i.e. int, double, Integer)
There are no necessary conditions.
True or false: If an array is already sorted, Linear Search / Sequential Search is more efficient than Binary Search.
True
False
Given this list:
1, 2, 4, 5, 6, 7, 8, 12, 14, 21, 22, 42, 53
How many comparisons are required to find 42 using the Binary Search?
3
2
10
5
Given this array:
1, 2, 4, 5, 6, 7, 8, 12, 14, 21, 22, 42, 53
How many comparisons are required to find 42 using the Linear Search / Sequential Search?
3
2
12
5
BMO the robot is programming a new game called “Open the box!” You give him a number and he tries to open a numbered box. He’s using Binary Search to accomplish this. Unfortunately, the boxes are not sorted. They are in the following order:
1, 3, 6, 9, 14, 10, 21
Which box can NEVER be found using binary search?
9
6
14
10
We are searching for a number key in a sorted list that has n elements. Under what circumstances will Linear Search / Sequential Search be more efficient than Binary Search?
key is the last element in the array
key is in the middle of the array
n is very large
key is the first element in the array
key does not exist in the array
What is the largest number of comparisons needed to perform a binary search on an array with 42 elements?
2
5
6
41
42
Identify the description of a linear search.
Put the elements in order, check each item in turn
Order elements,compare middle value,split list in order&loop
Elements do not need to be in order, check each item in turn
Randomize data, compare middle value, split list in order & loop
Identify the description of a binary search.
Put the elements in order, check each item in turn
Order elements,compare middle value,split list in order&loop
Elements do not need to be in order, check each item in turn
Randomize data, compare middle value, split list in order & loop
A linear search is to be performed on the list:
12, 6, 8, 1, 3
How many comparisons would it take to find the number 1?
1
2
3
4
A binary search is to be performed on the list:
3, 5, 9, 10, 23
How many comparisons would it take to find the number 9?
1
3
4
It can't find the number 9
What is the third step using Binary Search to look for the number 31 in this list: 1, 3, 4, 8, 10, 11, 16, 28, 31, 32, 45, 49, 51, 69, 75
Compare the number 28 to the given number
Compare the number 8 to the given number
Compare the number 32 to the given number
Compare the number 49 to the given number
Which of the following would be considered unreasonable?
3^n
3n
n^3
n^30
Which of the following is FALSE regarding undecidable problems and unreasonable time algorithms?
Unreasonable time algorithms can never be ran and will never produce a correct solution
Undecidable problems are a type of problem for which it has been proven that there simply is no algorithm that will always produce a correct result
Unreasonable problems grow in size so quickly, even for small inputs, that it is usually unreasonable to run that algorithm
With regards to undecidable problems, the issue isn't simply that it takes a long time, but that it is demonstrably impossible to write such an algorithm.
An algorithm was initially written sequentially. Later it was determined that a parallel solution was possible and so the algorithm rewritten. The times to run each version of the algorithm are included in the table above. What is the speedup of this parallel solution?
.5
2
120
40
Parallel algorithms typically will be faster than sequential algorithms
True
False
Which of the following is FALSE on why the speedup of a parallel algorithm will eventually reach some limit?
Parallel algorithms will only have portions of the algorithm that are parallel with no sequential portions
Running the algorithm on more computers can speed up the parallel portions
Sequential portions are not sped up by adding more computers
The sequential portion of the algorithm will eventually put a limit on the overall speedup
Adding additional parallel processes will always lead to the same amount of speedup
True
False
Because some portions are always still sequential, the benefits of adding more processors will go down and eventually the speedup reaches a limit
True
False
Which of the following is FALSE regarding the "Traveling Salesman Problem" discussed in Lesson 4?
For every new house to visit, the number of options for possible paths doubles
It can be solved with an algorithm, which checks each possible option.
The Traveling Salesman is an Optimization Problem, NOT a Decision Problem
It involves determining what is the shortest or most efficient path
Under which of the following conditions is it most beneficial to use a heuristic approach to solve a problem?
When the problem can be solved in a reasonable time and an approximate solution is acceptable
When the problem can be solved in a reasonable time and an exact solution is needed
When the problem cannot be solved in a reasonable time and an approximate solution is acceptable
When the problem cannot be solved in a reasonable time and an exact solution is needed
Parallel computing consists of both a parallel portion that is shared and ___________________ portion.
Distributed
Sequential
Unreasonable
Reasonable
To compute a speedup calculation:
Divide Parallel Time by Sequential Time
Subtract Sequential Time by Parallel Time
Substract Parallel Time by Sequential Time
Divide Sequential Time by Parallel Time
Some portions of your algorithm can’t be made parallel. Each additional processor helps a little less.
True
False
More and more processors can help improve the speedup calculation in that it's limitless
True
False
An algorithm was initially written sequentially. Later it was determined that a parallel solution was possible and so the algorithm rewritten. The times to run each version of the algorithm are included in the table above. What is the speedup of this parallel solution?
.75
1.33
300
2
Parallel Programs:
typically are slower programs than Sequential
cannot be slowed down even if only one of many devices is slow
can improve every single time more processors are added
are often times the fastest option, but there is a limit
How many searches will it take to find 10 in [1,3,5,7,10,12,15] using BINARY search?
3
4
5
6
Which algorithm uses a divide and conquer approach?
Linear Search
Binary Search
