wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Searching and Sorting Algorithm

Total questions: 71

Worksheet time: 1hrs 15mins

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.
What does a linear search do?
a)
Looks at the first item of data, then each one in turn, until it finds the data item requested
b)
Organises the data into alphabetical order
c)
Splits the data until the requested data is found
13.
What is an advantage of a linear search?
a)
It is very quick
b)
It only works with ordered lists
c)
It is a simple algorithm
14.
What does a binary search do?
a)
Looks at the first item of data, then each one in turn, until it finds the data item requested
b)
Converts all the data into binary
c)
Takes the data and splits it in half repeatedly until it finds the data item requested
15.
What does a binary search do?
a)
Looks at the first item of data, then each one in turn, until it finds the data item requested
b)
Converts all the data into binary
c)
Takes the data and splits it in half repeatedly until it finds the data item requested
16.
Which search algorithm would be best to use with ordered data?
a)
A binary search
b)
Either binary search or a linear search
c)
A linear search
17.
What is an advantage of a binary search
a)
It's very quick
b)
It only works with ordered lists
c)
It is a simple algorithm
18.
Where can Linear Search be performed?
a)
On letters
b)
On numbers
c)
Both
d)
None of these
19.
On average, which searching algorithm is more efficient?
a)
Binary Search
b)
Linear Search
20.
How many linear searches will it take to find the value 7 in the list [1,4,8,7,10,28]?
a)
2
b)
3
c)
4
d)
5
21.
Linear Search is faster than Binary search
a)
TRUE
b)
FALSE
c)
It depends on the scenario
22.
A Linear search algorithm requires data to be ordered.
a)
True
b)
False
23.
A linear search algorithm is also known as a...
a)
Binary search algorithm
b)
Bubble sort algorithm
c)
Sequential search algorithm
24.
What is an advantage of the Linear search algorithm?
a)
Performs well with small sized data sets
b)
Can be used on data sets with more than a million elements
c)
Is complicated to code
25.
What is a disadvantage of the Linear search algorithm?
a)
It will only work on a sorted data set
b)
May be too slow to process large data sets
26.
What will happen in a Linear search algorithm if no match is found?
a)
It continues to search in a never ending loop.
b)
"Item not found" is returned
27.
Which of these is a type of searching algorithm?
a)
Linear search
b)
Word search
c)
Search engine
28.

What does the left subtree of a node in a Binary Search Tree contain?

a)

Elements with duplicate keys

b)

Elements equal to the node

c)

Elements smaller than the node

d)

Elements greater than the node

29.

Which operation is used to find a key in a Binary Search Tree?

a)

remove(x)

b)

insert(x)

c)

update(x)

d)

search(x)

30.

How is insertion into a Binary Search Tree done?

a)

Recursively

b)

Using a stack

c)

Using a queue

d)

Iteratively

31.

What is the correct algorithm for deletion in a Binary Search Tree?

a)

Find the successor and remove it

b)

Find the predecessor and remove it

c)

Delete the root node

d)

Delete the leaf nodes

32.

What is the property of Binary Search Tree that makes searching easy?

a)

Elements are sorted in descending order

b)

Elements are sorted in ascending order

c)

Elements are randomly arranged

d)

Elements are stored in a linked list

33.

Which operation is used to insert a new key into a Binary Search Tree?

a)

search(x)

b)

remove(x)

c)

insert(x)

d)

find(x)

34.

What does the right subtree of a node in a Binary Search Tree contain?

a)

Elements greater than the node

b)

Elements smaller than the node

c)

Elements equal to the node

d)

Elements with duplicate keys

35.

Post order traversal :

a)

1a+b*c+d*e+f*g

b)

1abc*+de*f+g*+

c)

++a*bc*+*defg

d)

abc+*+defg*+*

36.

In Order traversal

a)

40 20 50 10 30

b)

40 50 20 30 10

c)

10 20 30 40 50

d)

50 40 20 30 10

37.

What is the MAXIMUM number of nodes in a binary search tree with height = 5 ?

a)

26-1

b)

25-1

c)

25

d)

26

e)

6

38.

What is the MINIMUM number of nodes in a binary search tree with height = 5?

a)

6

b)

5

c)

26-1

d)

25-1

e)

25

39.

What is the worst-case runtime of lookUp/get in a binary search tree?

a)

O(n)

b)

O(logn)

c)

O(1)

d)

O(n2)

40.

What is the worst-case runtime of lookUp/get in a *perfectly balanced* binary search tree?

a)

O(logn)

b)

O(n)

c)

O(1)

d)

O(n2)

41.
When deleting from a binary search tree, if the node being deleted has 2 children, we replace the entry with ____.
a)
the inorder successor
b)
null
c)
the left child
d)
the right child
e)
the parent
42.

Which method checks that two objects are equivalent?

a)

toString

b)

equals

c)

compareTo

d)

binarySearch

43.

Binary Search works best on

a)

Equally effective on sorted and unsorted lists

b)

Unsorted lists

c)

Sorted lists

d)

None of the above

44.

If the specified value is present binary search will return

a)

true

b)

false

c)

the value

d)

the position of the value

45.
Compares pairs of items and swaps them if they are in the wrong order. Each pair in the list is checked.
a)
Bubble sort
b)
Insertion sort
46.
The process keeps repeating until there are no swaps in a pass.
a)
Bubble sort
b)
Insertion sort
47.
Efficient way to check if a list is already in order.
a)
Bubble sort
b)
Insertion sort
48.
Inefficient way to sort a list.
a)
Bubble sort
b)
Insertion sort
49.
Takes each item in turn and puts it in the right place using the first item in the list as a starting point.
a)
Bubble sort
b)
Insertion sort
50.
Starts by looking at the second item and compares it to all items before it in order to insert it in the right place.
a)
Bubble sort
b)
Insertion sort
51.
Repeats the process for the rest of the items until the last item has been inserted in the correct place.
a)
Bubble sort
b)
Insertion sort
52.
Very quick to add items in an already ordered list
a)
Bubble sort
b)
Insertion sort
53.
Good for small lists.
a)
Bubble sort
b)
Insertion sort
c)
Bubble sort and insertion sort
54.
Doesn’t use much memory.
a)
Bubble sort
b)
Insertion sort
c)
Bubble sort and insertion sort
55.
Does not cope well with very large lists.
a)
Bubble sort
b)
Insertion sort
c)
Bubble sort and insertion sort
56.
Speed of sort depends on how unordered the list is.
a)
Bubble sort
b)
Insertion sort
c)
Bubble sort and insertion sort
57.
Which type of sort algorithm is this?
a)
Bubble
b)
Merge
c)
Insertion
58.
Compares pairs of items and swaps them if they are in the wrong order. Each pair in the list is checked.
a)
Bubble sort
b)
Insertion sort
59.
Inefficient way to sort a list.
a)
Bubble sort
b)
Insertion sort
60.
Which type of sort algorithm is this?
a)
Bubble
b)
Merge
c)
Insertion
61.
A bubble sort goes through each pair in a list and swaps them if not in order.
a)
True
b)
False
62.
What does a bubble sort do?
a)
Sorts a list by comparing two items that are side by side, to see which is out of order
b)
Separates a list of data into different collections of data, before sorting and gathering back into a list
c)
Finds an item of data in a list
63.
Why does a bubble sort do a final pass even when the data is in the correct order?
a)
To save the data
b)
It does not recognise that the data is in order until the final pass requires no changes
c)
It needs to do this to put the data back in to a list
64.
Which of the following is an advantage of a bubble sort?
a)
It is a very small and simple computer program
b)
It takes a very long time to run
c)
It is very quick
65.

Which sorting algorithm may make multiple swaps per pass?

a)

Bubble Sort

b)

Selection Sort

c)

Insertion Sort

d)

Merge Sort

66.

What does a sorting algorithm do?

a)

Puts numbers in order

b)

Puts data in order

c)

Finds a bit of data

67.

How many passes are required to sort a list with 5 elements?

a)

5

b)

4

c)

10

d)

2

68.
We are sorting the following list in ascending order:
 
1    4    2    9    3    8    5
 
What does the list look like after one pass of the insertion sort algorithm. 
a)
1 4 2 9 3 8 5
b)
4 2 9 3 8 5 1
c)
4 1 2 9 3 8 5
69.
Which type of sort algorithm is this?
a)
Bubble
b)
Merge
c)
Insertion
70.
Which type of sort algorithm is this?
a)
Bubble
b)
Merge
c)
Insertion
71.
The following lists represent 3 passes of a sorting algorithm. Which algorithm is being used to sort the list?
 
4    8    6    2    5    7 
4    8    6    2    5    7 
4    6    8    2    5    7
a)
Bubble Sort
b)
Selection Sort
c)
Insertion Sort