Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
Question 41

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

Algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Algorithms

159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank