Skip to content

Course home

Efficiency of algorithms

Efficiency of algorithms

EasyMedium
123456
Question 6

Two programs are written to calculate the total number of fixtures in a double round-robin tournament, where N N\,N teams play each other exactly twice (once at home and once away).

Program A

teams = int(input("Enter number of teams: "))
fixtures = 0
for i in range(1, teams):
    fixtures = fixtures + 2 * i
print(fixtures)

Program B

teams = int(input("Enter number of teams: "))
fixtures = teams * (teams - 1)
print(fixtures)

Justify why Program B is more efficient than Program A, particularly when the user enters a very large number of teams.

[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