Skip to content

Course home

Sign up

Computational thinking

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
Question 73

A marine biology research team records the migratory distances of tracked whale sharks in a 2D array named shark_telemetry. Each record in the array is structured as [shark_id, tag_code, migration_distance].

The team uses the following unoptimized bubble sort algorithm to sort the records in ascending order of their migration distances:

1  # shark_telemetry has the format [shark_id, tag_code, migration_distance]
2
3  PROCEDURE sortTelemetry()
4  BEGIN PROCEDURE
5      SET swap_var TO []
6      FOR i FROM 0 TO LENGTH(shark_telemetry) - 1 DO
7          FOR j FROM 0 TO LENGTH(shark_telemetry) - 2 DO
8              IF shark_telemetry[j][2] > shark_telemetry[j + 1][2] THEN
9                  SET swap_var TO shark_telemetry[j]
10                 SET shark_telemetry[j] TO shark_telemetry[j + 1]
11                 SET shark_telemetry[j + 1] TO swap_var
12             END IF
13         END FOR
14      END FOR
15  END PROCEDURE

Describe how the implementation of this algorithm can be modified to improve its efficiency.

[4]
Markscheme

Computational thinking Questions

  1. GCSE
  2. /Computer Science
  3. /Computational thinking

Question bank