Computational Thinking, Searching & Sorting Algorithms (OCR GCSE Computer Science): Exam Questions

Exam code: J277

2 hours29 questions
1
2 marks

State the name of each of the following computational thinking techniques.

Breaking a complex problem down into smaller problems.

Hiding or removing irrelevant details from a problem to reduce the complexity.

2
4 marks

The following table contains several definitions of terms that are used in Computer Science.

Letter

Definition

A

Cleaning up data entered by removing non-standard characters

B

Hiding or removing irrelevant details from a problem to reduce complexity

C

Checking that the user is allowed to access the program

D

Breaking a complex problem down into smaller problems

E

Repeating elements of a program

F

Converting one data type to another, for example converting an integer to a real number

Write the letter of the definition that matches each keyword in each space.

Keyword

Letter

Decomposition

Abstraction

Input sanitisation

Casting

3a
1 mark

A list of valid discount codes is shown below.

[NIC12B, LOR11S, STU12M, VIC08E, KEI99M, WES56O, DAN34S]

State one reason why a binary search would not be able to be used with this data.

3b
1 mark

Give the name of one searching algorithm that would be able to be used with this data.

4a
1 mark

State one pre-requisite for a binary search algorithm.

4b
1 mark

Tick (✓) one box to identify the name of the sorting algorithm that splits data into individual items before recombining in order.

  • Bubble sort

  • Insertion sort

  • Merge sort

5a
1 mark

Students take part in a sports day. The students are put into teams.

Students gain points depending on their result and the year group they are in. The points are added to the team score.

The team with the most points at the end of the sports day wins.

Abstraction and decomposition have been used in the design of the sports day program.

Identify one way that abstraction has been used in the design of this program.

5b
1 mark

Identify one way that decomposition has been used in the design of this program.

1a
3 marks

A program stores the following list of positive and negative numbers. The numbers need sorting into ascending order using a merge sort.

45

12

-99

100

-13

0

17

-27

The first step is to divide the list into individual lists of one number each. This has been done for you.

Complete the merge sort of the data by showing each step of the process.

Seven numbers inside individual boxes: 45, 12, -99, 100, -13, 0, 17, and -27. The boxes are arranged in a horizontal line.
1b
4 marks

Once the numbers are in order, a binary search can be run on the data.

Describe the steps a binary search will follow to look for a number in a sorted list.

1c
2 marks

A linear search could be used instead of a binary search.

Describe the steps a linear search would follow when searching for a number that is not in the given list.

2
4 marks

A sample of data is shown in Fig. 4.

amber

house

kick

moose

orange

range

wind

zebra

Fig. 4

Show the stages of a binary search to find the word zebra using the data shown in Fig. 4.

3a
5 marks

Tick (✓) one box in each row to identify whether each statement about the insertion sort is true or false.

Statement

True (✓)

False (✓)

The list of words is initially split into a sorted set and an unsorted set.

The insertion sort uses a divide stage and then a conquer stage.

The list of words must be in order before the insertion sort can start.

Each word is inserted into the correct place in the array, one by one.

The insertion sort will not work because the word “wall” appears twice.

3b
4 marks

The sorted list of words is shown below.

flour

house

pumpkin

wall

wall

Explain how a binary search would be used to try to find whether the word “house” appears in this list.

4
4 marks

Taylor has used computational thinking techniques to develop an algorithm.

Give two computational thinking techniques that Taylor could have used, and describe how.

5
4 marks

The following names of students are stored in an array with the identifier studentnames.

studentnames = ["Rob", "Anna", "Huw", "Emma", "Patrice", "Iqbal"]

Describe the steps that a linear search would take to find Anna in studentnames

6
5 marks

The names of students are sorted into ascending alphabetical order using an insertion sort.

Complete the following diagram to show the stages an insertion sort would take to complete this task.

Each row represents one pass of the insertion sort algorithm.

You may not need to use all empty rows.

A table with seven columns labeled
7a
2 marks

Elliott plays football for OCR FC.

He wants to create a program to store the results of each football match they play and the names of the goal scorers.

Elliott wants individual players from the team to be able to submit this information.

Define what is meant by abstraction.

7b
1 mark

Give one example of how abstraction could be used when developing this program in part (a).

8a
4 marks

A library sorts their books based on a book code.

Show the steps that a merge sort would take to put the following list of book codes into ascending alphabetical order (from A to Z).

POE12 , BAC97 , FLY77 , JAV16 , TAL86 , AND18 , ZAR09 , HOP86

8b
2 marks

Explain one advantage of a merge sort compared to a bubble sort.

9
3 marks

Show how a binary search will be used to find the number 10 in the following data set:

1  2  5  6  7  10  20

10
4 marks

The student names for a team are stored in an array with the identifier theTeam

An example of the data in this array is shown:

Table shows array 'theTeam' with indexes 0 to 5, listing names: Ali, Eve, Ling, Nina, Sarah, Tom. Index is in top row, names in bottom row.

A linear search function is used to find whether a student is in the team. The function:

• takes a student name as a parameter
• returns True if the student name is in the array
• returns False if the student name is not in the array

Complete the design of an algorithm for the linear search function.

function linearSearch(studentName)

    for count = 0 to …………….….....……………

        if theTeam[……………..…...…….………] == …………….….....…………… then

            return …………….….....……………

        endif

    next count

    return False

endfunction
11
5 marks

A list of numbers is stored in the following order:

42, 17, 8, 31, 25, 14

Describe how the list would be sorted into ascending order using an insertion sort

You must show the list after passes 1, 2, 3 and 4, and then give the final sorted list

12
5 marks

A list of words is stored in the following order:

grape, apple, cherry, banana, fig, date

Show how the list would be sorted into alphabetical order using an insertion sort

You must show the list after passes 1, 2, 3 and 4, and then give the final sorted list

13
4 marks

A warehouse organises its inventory using product codes.

Show the steps that a merge sort would take to put the following list of product codes into ascending numerical order (from smallest to largest).

847 , 215 , 632 , 419 , 756 , 128 , 903 , 541

14
4 marks

A library organises its book collection using reference numbers.

Show the steps that a bubble sort would take to put the following list of reference numbers into ascending numerical order (from smallest to largest).

523 , 187 , 412 , 695 , 234 , 876 , 341 , 158

15
4 marks

A sports club records the scores of its members using player IDs.

Describe the steps that a bubble sort would take to put a list of player IDs into ascending numerical order (from smallest to largest).

742 , 315 , 628 , 891 , 456 , 203 , 567 , 134

1
4 marks

A program uses a file to store a list of words that can be used in a game.

A sample of this data is shown in Fig. 3.

crime

bait

fright

victory

nibble

loose

Fig. 3

Show the stages of a bubble sort when applied to data shown in Fig. 3.

2
3 marks

An insertion sort algorithm is used to sort a dataset of game scores from smallest to largest

game_scores = [101, 110, 130, 50, 66]

To perform an insertion sort, a count-controlled loop must be used.

Describe the purpose of the count-controlled loop and give an example of what the loop would look like.

Purpose

Example

3
5 marks

Describe the steps involved in performing a bubble sort on the list in Fig. 1. Show the state of the list after each complete pass through the list.

12

34

45

23

8

39

Fig. 1

4
3 marks

Explain why the removal of geographical accuracy in a city bus map is a necessary form of abstraction for a computer

5
3 marks

Justify the use of decomposition in a large-scale banking app, focusing on independent testing

6
4 marks

Analyse how abstraction and decomposition help when designing an algorithm to solve a problem

7
4 marks

A dataset of 1,000,000 items is unsorted.

Evaluate the effectiveness of using a binary search in this scenario

8
3 marks

Explain a situation where a linear search would be more efficient than a binary search, even when the list is sorted

9
4 marks

Explain why a merge sort is often preferred over a bubble sort when sorting a very large list, such as 10 million website users