wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Algorithms, linear and binary search questions

Total questions: 20

Worksheet time: 12mins

Name
Class
Date
1.
What is an Algorithm?
a)
A chart showing the flow of a series of events
b)
Step-by-step instructions used to solve a problem
c)
A decision arrived at by following instructions
d)
A computer program that follows a chart
2.

While the program is running, if the program makes a choice if it should run some code or not, it is called a...

a)

variable

b)

sequence

c)

selection

d)

mistake

3.

When a program repeats, looping over the same sequence, it is called...

a)

iteration

b)

a variable

c)

an instruction

4.

Instructions carried out one after another in order is a...

a)

List

b)

Sequence

c)

Collection

d)

Series

5.

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

6.

Only allowing one bit of code to run when something happens.

Example:

• Only run this bit of code “When” or “If” this bit has run

• WHEN you press on the keyboard, on the arrows, DO move.

a)

Selection

b)

Sequence

c)

Iteration

d)

Variable

7.
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
8.
Select the best description to explain what a linear search algorithm is.
a)
Put the elements in order, check each item in turn.
b)
Put the elements in order, compare with the middle value, split the list in order and repeat.
c)
Elements do not need to be in order, check each item in turn.
d)
Elements do not need to be in order, compare to the middle value, split the list in order and repeat
9.

Select the best description to explain what a binary search algorithm is.

a)

Put the elements in order, check each item in turn.

b)

Put the elements in order, compare with the middle value, split the list in order and repeat.

c)

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

d)

Elements do not need to be in order, compare to the middle value, split the list in order and repeat

10.
A linear search is to be performed on the list:
12   6   8  1  3
How many comparisons would it take to find number 1?
a)
1
b)
2
c)
3
d)
4
11.
A binary search is to be performed on the list:
3  5  9  10  23
How many comparisons would it take to find number 9?
a)
0-1
b)
2-3
c)
4-5
d)
I can't find the number 9
12.

Which symbol is Input/Output?

a)
b)
c)
d)
13.

What does this symbol represent?

a)

Input/Output

b)

Decision

c)

Off-Page Connector

d)

Process

14.

What is the difference between a flowchart and pseudocode?

a)

A flowchart is diagrammatic whilst pseudocode is written in a programming language

b)

A flowchart is textual but pseudocode is diagrammatic

c)

A flowchart is a diagrammatic description of an algorithm whilst pseudocode is a textual description of an algorithm

d)

A flowchart and pseudocode are the same thing

15.

An Algorithm asks the user to enter their gender (M or F) and prints out a different comment depending on what they entered.

This is an example of which of the algorithm constructs?

a)

Decision (Selection)

b)

Loop (Iteration)

c)

Order (Sequence)

d)

All of the above

16.

What is the best case scenario in a linear search?

a)

The item being searched for is at the end of the list

b)

The item being searched for is at the start of the list

c)

The item is not present in the list

d)

The item being searched for is exactly in the middle of the list

17.

How is the midpoint of the list calculated?​

a)

midpoint= round ((first_element+last_element)/2)​

b)

midpoint=(lower_bound+upper_bound)/2​

c)

midpoint= round ((lower_bound+upper_bound)/2)​

d)

midpoint= round ((lower_bound+upper_bound))

18.
1,31,56,58, 64,66,70. To find 31, what is the first set of numbers left after binary search?
a)
1,31,56
b)
31,56,58
c)
58,64,66
d)
64,66,70
19.
What is the second step of the binary search algorithm
a)
discard half of the list
b)
swap the two haves
c)
check each half separately
d)
half them again, check all
20.

What is an Array?

a)

A group of elements of same data type.

b)

An array contains more than one element

c)

Array elements are stored in memory in continuous or contiguous locations.

d)

All the above.