wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CompuScholar Chapter 5

Total questions: 28

Worksheet time: 14mins

Name
Class
Date
1.

What shape would be drawn with this algorithm?

a)

A triangle with side length 100

b)

A five-sided star

c)

A pentagon with side length 100

d)

A rectangle with side length 500

2.

How could you change this algorithm with parameters to draw any regular polygon with any side length?

a)

I. Replace the 100 with a parameter for side length

b)

II. Replace the 5 with a parameter for number of sides

c)

III. Replace the 72 with 360 divided by parameter for number of sides

d)

I and II

e)

I, II, and III

3.

This procedure should draw a square with side legth L, but it has a bug. How can you fix it?

a)

Change the 90 to "get L"

b)

Change the 50 to "get L"

c)

Change the 4 to "get L"

d)

Change the 90 and the 50 to "get L"

4.

What code should be added to the procedure so that increment(x) adds x to the variable z?

a)
b)
c)
d)
5.

Define a procedure named procTwoParams that multiplies its two parameters and assigns the result to the global variable Z.

a)
b)
c)
d)
6.

Which code would successfully navigate the robot to the shaded square?

a)

moveAndTurn(1, 2)

moveAndTurn(3, 5)

moveAndTurn(0, 3)

b)

moveAndTurn(3, 1)

moveAndTurn(6, 3)

moveAndTurn(3, 1)

c)

moveAndTurn(2, 1)

moveAndTurn(5, 1)

moveAndTurn(2, 1)

d)

moveAndTurn(2, 1)

moveAndTurn(5, 3)

moveAndTurn(2,0)

7.

Which is a procedure that would NOT take a parameter?

a)

A procedure that greets your user by name

b)

A procedure that draws a line segment of a certain length

c)

A procedure that doubles a number

d)

A procedure that resets all of your global variables to 0

8.

You want to search this list for an 18, which search algorithm makes the most sense to use and why?

{3, 11, -3, 5, 0, 7, 18}

a)

Binary Search, because it's the most efficient

b)

Sequential Search, because the list is not in order

c)

Bubble Sort, because the highest number rises to the top

d)

Merge Sort, because it's more efficient than bubble sort

9.

You have a suit of cards and you are looking for the Ace. In which scenario can you use binary search?

a)

The cards are shuffled

b)

The suit is hearts

c)

The ace is on top

d)

The suit is in numerical order

10.

How many passes does Bubble Sort take to sort 16 items?

a)

16 passes

b)

4 passes

c)

5 passes

d)

13 passes

11.

After one pass of the merge sort, what does this data look like?

{1, 5, 25, 4, 11, 3, 15, 16}

a)

{1, 5}, {4, 25} {3, 11} {15, 16}

b)

{1, 3} {4, 5} {11, 15} {16, 25}

c)

{1, 5, 4, 11, 3, 15, 16, 25}

d)

{1, 4, 5, 25} (3, 11, 15, 16}

12.

After one pass of the bubble sort, what does this data look like?

{2, 6, 9, 4, 5, 1, 11}

a)

{2, 6, 9, 4, 5, 1, 11}

b)

{2, 6, 4, 5, 1, 9, 11}

c)

{1, 2, 4, 5, 6, 9, 11}

d)

{2, 6} {4, 9} {1, 5} {11}

13.

What does it mean for a cipher to be a substitution cipher?

a)

Encoding and decoding use the same key

b)

The cipher is easy to for spies to decode

c)

Each letter is replaced by a new letter in the cipher alphabet

d)

It is impossible to decode unless you intercept the key

14.

Encode "Hello" using a Caesar cipher shift of 3

a)

lohel

b)

khoor

c)

ebiil

d)

lipps

15.

Define a function named hello(x) that concatenates the word 'hello' and the parameter x, with a space in between. For example hello("world") would result in "hello world".

a)
b)
c)
d)
16.

Write a function, double(x), that doubles the value of its single argument.

a)
b)
c)
d)
17.

What value does this function return?

a)

The square root of its parameter, x

b)

The parameter, x to the power of 2

c)

Double the parameter, x

d)

Nothing because you never intialized the global variable, x

18.

What is the difference between a function and a procedure?

a)

A function returns a value, but a procedure doesn't

b)

A procedure can use parameters, but a function can't

c)

Procedures can have user-defined names, but functions can't be named

d)

You can put comments in a procedure, but you can't add comments to a function

19.

Why can't a compiler tell you that you made a semantic error in your code?

a)

A compiler only understands machine language

b)

Compilers only look at executable files, not code

c)

A semantic error is a mistake in logic and the compiler doesn't know what the programmer wanted to create

d)

Compilers are specific to machines, like iPhones or PCs and so they can't find errors in all types of code

20.

What would be the value of the global variable, result if this loop successfully runs?

a)

Impossible to tell because you never initialized the global variable, number

b)

5

c)

120

d)

1

21.

For a list of 1000 numbers, at most how many guesses would it take using binary search to guess the secret number if after each guess you were told whether your guess was too high or too low or just right?

a)

9

b)

10

c)

1000

d)

500

22.

For a list of 1000 numbers, at most how many guesses would it take using sequential search to guess the secret number?

a)

9

b)

10

c)

500

d)

1000

23.

Which search algorithm takes log2(x) lookups to find a number in a list (worst case)?

a)

binary

b)

sequential

c)

merge

d)

bubble

24.

To say that bucket sort is more efficient than bubble sort means that _________________.

a)

No matter the list size, bucket sort always takes less time than bubble sort

b)

Bucket sort is faster for long lists than bubble sort

c)

Bucket sort requires fewer comparisons than bucket sort

d)

There is no reason to ever use bubble sort

25.

Which algorithm uses about N2 comparisons to sort a list of N elements?

a)

Bucket

b)

Merge

c)

Bubble

d)

Binary

26.

Which algorithm uses about N log(N) comparisons to sort a list of N items?

a)

Bucket

b)

Bubble

c)

Merge

d)

Binary

27.

What is an intractable problem?

a)

One for which an algorithm doesn't exist to solve it

b)

One which could be solved algorithmically but it would take too long to be practical

c)

One which you could solve with a repetition algorithm

d)

One which has no real-world application

28.

Why would you use a heuristic algorithm?

a)

You are too lazy to program a good algorithm

b)

An approximate solution is good enough and the problem is intractable

c)

You want the exact answer to an intractable problem

d)

You want an approximate answer to an undecidable problem