Skip to content

Course home

Sign up

Computational thinking

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
Question 48

An e-sports tournament system stores player rankings in a 2D array named leaderboard. Each record in the array has the format [playerID, tag, score].

The system uses the following pseudocode program to sort the leaderboard in descending order of scores:

1  # leaderboard has the format [playerID, tag, score]
2
3  PROCEDURE sortLeaderboard()
4  BEGIN PROCEDURE
5      SET temp TO []
6      FOR outer FROM 0 TO LENGTH(leaderboard) - 1 DO
7          FOR inner FROM 0 TO LENGTH(leaderboard) - 2 DO
8              IF leaderboard[inner][2] < leaderboard[inner + 1][2] THEN
9                  SET temp TO leaderboard[inner]
10                 SET leaderboard[inner] TO leaderboard[inner + 1]
11                 SET leaderboard[inner + 1] TO temp
12             END IF
13         END FOR
14      END FOR
15  END PROCEDURE

Describe how the implementation of this bubble sort algorithm could be refined to make it more efficient.

[4]
Markscheme

Computational thinking Questions

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

Question bank