No student devices needed. Know more
24 questions
What does an algorithm need to be (choose all that apply)?
Clear instructions
Exact
Easy to understand
Complex
What is the purpose of pseudocode?
To program a computer
So we can see the different symbols
It helps us with the variables
It helps us plan the code line by line
Flow charts are helpful to us when planning
Which of these does NOT represent an algorithm?
Following recipe instructions
Working out how an engine works
Tying your shoelaces
Making a cup of coffee
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
Why is iteration important?
It determines the order in which instructions are carried out
It allows code to be simplified by removing duplicated steps
It allows multiple paths through a program
Which statement is used to implement iteration?
IF
WHILE
Which statement is used to implement selection?
IF
WHILE
Why is selection important?
Selection allows us to include more than one path through a solution
Selection allows us to repeat steps in a solution
Selection allows us make our solution more efficient
myAge = 12
PRINT "Next year I will be: "
PRINT myAge + 1
PRINT "In two years I will be: "
PRINT myAge + 2
PRINT "In three years I will be: "
PRINT myAge + 3
Iteration
Sequencing
Selection
IF LENGTH( password ) < 8:
PRINT ("Your password is not valid!")
Iteration
Sequencing
Selection
WHILE (timer > 0):
PRINT "Carry on playing..."
timer = timer - 1
Iteration
Sequencing
Selection
IF goalsIn == goalsOut:
PRINT "It's a draw"
ELSE IF goalsIn > goalsOut:
PRINT "Player 1 wins!"
ELSE:
PRINT "Player 2 wins!"
Iteration
Sequencing
Selection
Explore all questions with a free account