wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

OCR GCSE CS - 2.1 ERL sorts and searches

Total questions: 9

Worksheet time: 5mins

Name
Class
Date
1.

while searchIndex < _______(searchList)

What is the missing command to check how big the list is?

a)

print

b)

input

c)

len

d)

div

2.

How does a bubble sort ensure no data is lost when swapping values?

a)

Adds it to a list

b)

Converts it to an integer

c)

Uses a temporary variable

d)

Stores it in a tuple

3.

What algorithm does this represent?

searchIndex = 0

while searchIndex < len(searchList)

if searchList[searchIndex] == searchItem then

return true

endif

searchIndex = searchIndex + 1

endwhile

return false

a)

Binary search

b)

Linear search

c)

Bubble sort

d)

Insertion sort

4.

Which search or sort finds the midpoint, checks if what they are looking for is higher or lower and discards the half not needed?

(a)  

5.

midPoint = (start + end) DIV 2

Which search or sort would this line of code belong to?

a)

Binary search

b)

Linear Search

c)

Merge sort

d)

Insertions sort

6.

temp = sortList [sortCount]

sortList[sortCount] = sortList[sortCount + 1]

sortList[sortCount + 1] = temp

Which search or sort would this line of code belong to?

a)

Binary search

b)

Linear Search

c)

Merge sort

d)

Insertions sort

e)

Bubble sort

7.

temp = sortList [sortCount]

sortList[sortCount] = sortList[sortCount + 1]

sortList[sortCount + 1] = temp

Which does the above code do?

a)

Puts the value into a temporary variable

b)

Deletes the variable

c)

Goes to the next value in the list

d)

Creates a new list

8.

Which line of code checks to see if an element in sortList is greater than the one to the left of it. It then repeats this working backwards through the list, until the element is in the correct place.

a)

return sortList

b)

for sortCount = 1 to len(sortList) - 1

c)

temp = sortList [listIndex]

d)

while listIndex > 0 and sortList[listIndex] < sortList[listIndex-1]

9.

Which algorithm splits the arrays into sub-arrays of 1 element.

a)

Binary search

b)

Linear Search

c)

Merge sort

d)

Insertions sort

e)

Bubble sort