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).
teams = int(input("Enter number of teams: "))
fixtures = 0
for i in range(1, teams):
fixtures = fixtures + 2 * i
print(fixtures)
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.
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.