Skip to content

Course home

Efficiency of algorithms

Efficiency of algorithms

EasyMedium
123456
Question 1

A game developer is designing a script to calculate the total experience points (XP) required for a player to reach level NNN. The XP required for each level i i\,i is defined as 50i50i50i. The developer considers two different algorithms to perform this calculation.

Algorithm P

N = int(input("Enter level: "))
total_xp = 0
for i in range(1, N + 1):
    total_xp = total_xp + (50 * i)
print(total_xp)

Algorithm Q

N = int(input("Enter level: "))
total_xp = 25 * N * (N + 1)
print(total_xp)

Algorithm Q is more efficient than Algorithm P.

Justify this statement.

[2]
Markscheme

Efficiency of algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Efficiency of algorithms

15 exam-style questions on AQA GCSE Computer Science Efficiency of algorithms. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank