wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Code.org AP Computer Science Principles Unit 6

Total questions: 24

Worksheet time: 24mins

Name
Class
Date
1.

What does an algorithm need to be (choose all that apply)?

a)

Clear instructions

b)

Exact

c)

Easy to understand

d)

Complex

2.
What is pseudocode?
a)
Simplified programming language, that is not a specific language
b)
Complicated programming language
c)
Simple programming language, which is linked to a specific language
d)
A type of cheese
3.

What is the purpose of pseudocode?

a)

To program a computer

b)

So we can see the different symbols

c)

It helps us with the variables

d)

It helps us plan the code line by line

e)

Flow charts are helpful to us when planning

4.

Which of these does NOT represent an algorithm?

a)

Following recipe instructions

b)

Working out how an engine works

c)

Tying your shoelaces

d)

Making a cup of coffee

5.

If it is AFTER 7am, what do you need to do?

a)

Take the bus

b)

Take the subway

c)

Check the time

d)

Leave home

6.

You are at the yellow arrow, pointing in the direction indicated. How would you move to fill in the 2 black squares?

a)

Straight, Turn right, Straight x 1, Fill Square, Straight x 2, Turn left, Straight x 1, Fill Square

b)

Straight x 2, Turn right, Straight x 1, Fill Square, Straight x 2, Turn left, Straight x 1, Fill Square

c)

Straight x 2, Turn right, Straight x 1, Fill Square, Straight x 2, Turn right, Straight x 1, Fill Square

d)

Straight x 2, Turn right, Straight x 1, Fill Square, Straight x 2, Turn left, Straight x 2, Fill Square

7.

What must be true before performing a binary search?

a)

The elements must be sorted.

b)

It can only contain binary values.

c)

The elements must be some sort of number (i.e. int, double, Integer)

d)

There are no necessary conditions.

8.

True or false: If an array is already sorted, Linear Search / Sequential Search is more efficient than Binary Search.

a)

True

b)

False

9.

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?

a)

3

b)

2

c)

10

d)

5

10.

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?

a)

3

b)

2

c)

12

d)

5

11.

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?

a)

9

b)

6

c)

14

d)

10

12.

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?

a)

key is the last element in the array

b)

key is in the middle of the array

c)

n is very large

d)

key is the first element in the array

e)

key does not exist in the array

13.

What is the largest number of comparisons needed to perform a binary search on an array with 42 elements?

a)

2

b)

5

c)

6

d)

41

e)

42

14.

Identify the description of a linear search.

a)

Put the elements in order, check each item in turn

b)

Order elements,compare middle value,split list in order&loop

c)

Elements do not need to be in order, check each item in turn

d)

Randomize data, compare middle value, split list in order & loop

15.

Identify the description of a binary search.

a)

Put the elements in order, check each item in turn

b)

Order elements,compare middle value,split list in order&loop

c)

Elements do not need to be in order, check each item in turn

d)

Randomize data, compare middle value, split list in order & loop

16.
Which of the following is an example of the use of heuristics?
a)
Trying every possible combination of letters when unscrambling a word
b)
Considering each possible move when playing chess
c)
Using the formula “area=length x width” to find the area of a rectangle
d)
Playing chess using a defensive strategy that has often been successful for you
17.

Why is iteration important?

a)

It determines the order in which instructions are carried out

b)

It allows code to be simplified by removing duplicated steps

c)

It allows multiple paths through a program

18.

Which statement is used to implement iteration?

a)

IF

b)

WHILE

19.

Which statement is used to implement selection?

a)

IF

b)

WHILE

20.

Why is selection important?

a)

Selection allows us to include more than one path through a solution

b)

Selection allows us to repeat steps in a solution

c)

Selection allows us make our solution more efficient

21.

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

a)

Iteration

b)

Sequencing

c)

Selection

22.

IF LENGTH( password ) < 8:

PRINT ("Your password is not valid!")

a)

Iteration

b)

Sequencing

c)

Selection

23.

WHILE (timer > 0):

PRINT "Carry on playing..."

timer = timer - 1

a)

Iteration

b)

Sequencing

c)

Selection

24.

IF goalsIn == goalsOut:

PRINT "It's a draw"

ELSE IF goalsIn > goalsOut:

PRINT "Player 1 wins!"

ELSE:

PRINT "Player 2 wins!"

a)

Iteration

b)

Sequencing

c)

Selection