wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Binary and Linear Search

Total questions: 18

Worksheet time: 54mins

Name
Class
Date
1.
Which type of lists or data sets are linear searching algorithms used for?
a)
Unsorted lists or data sets
b)
Sorted lists or data sets
2.
Which type of lists or data sets are binary searching algorithms used for?
a)
Unsorted lists or data sets
b)
Sorted lists or data sets
3.
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
4.

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

5.
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
6.
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
7.
A binary search is to be performed on the list:
1  5  10  13  48  68  100  101
How many comparisons would it take to find number 101?
a)
0-1
b)
1-2
c)
3-4
d)
4-5
8.
Describe an advantage of a linear search algorithm
a)
Data does not need to be in order.
b)
Performs well over large ordered lists.
c)
Can only work on an ordered list.  If unordered must use a linear search.
d)
Slow with large data sets.
9.

Which of these are search algorithms?

a)

Bubble

b)

Merge

c)

Linear

d)

Binary

e)

Caesar

10.

Which of these algorithms searches for something by first looking in the middle of a list?

a)

Bubble sort

b)

Merge sort

c)

Linear search

d)

Binary search

11.

Which of these algorithms eliminates half of its possibilities each time it makes a check?

a)

Binary search

b)

Bubble sort

c)

Merge sort

d)

Linear search

12.

An array with 32 elements is input to a binary search algorithm. How many maximum number of comparisons are performed?​

a)

32

b)

16

c)

8

d)

5

13.

An array with 32 elements is input to a linear search algorithm. How many maximum number of comparisons are performed?​

a)

32

b)

16

c)

8

d)

5

14.

Complete the sentence: The lower half of the list is discarded if the value at midpoint is …………………….. item searched.​

a)

less than​

b)

greater than​

c)

equal to

15.

True or False: The upper half of the list is discarded if the value at midpoint is greater than item searched.​

a)

True

b)

​False​

16.

How are procedures a form of abstraction?

a)

By being able to use a procedure without knowing how it works

b)

By understanding the code in a procedure to use it correctly

c)

By modifying the code in a procedure for a particular use

d)

By eliminating the use of procedures to make the code more abstract

17.

What is displayed after the following code is run?

a)

Even Even Even

b)

Odd Even Odd

c)

Odd Odd Odd

d)

Even Even Odd

18.

Which of the following will result in an infinite loop?

a)

b)

c)

d)