GCSE Computer Science (CCEA)

Topic Summaries

ALGORITHMS AND PROGRAMMING: Designing, creating, and refining algorithms

Refining algorithms

  • Turning a designed algorithm into executable code requires the correct syntax and an accurate translation of logic.
  • Refining an algorithm can involve: 
    • Improving an algorithm after testing it 
    • Fixing logic or adding validation
    • Optimising performance or clarity 
  • For example:
    • Original code doesn’t check for empty input → add a condition to handle it. 
    • Original algorithm uses multiple nested ifs → simplify with elif.

# Original algorithm

age = int(input(“Enter age:”))

print(“Age recorded”)

 
 

# Refined algorithm

age = int(input(“Enter age:”))

 
 

if age < 0 or age > 120:

print(“Invalid age”)

else:

print(“Age recorded”)

  • Refinement is often based on test results. More refined algorithms be easier to read and maintain but may have more or fewer steps depending on whether more specificity or efficiency is needed.

# Original algorithm

numbers = [2, 4, 6, 8]

total = 0

 
 

for i in range(0, len(numbers)):

total = total + numbers[i]

 
 

print(total)

 
 

# Refined algorithm

numbers = [2, 4, 6, 8]

total = sum(numbers)

 
 

print(total)

Unlock Refining algorithms

Sign up to unlock the rest of this topic — plus every other topic, video, flashcard set and eBook guide in your SnapRevise Digital subscription.

Cancel anytime — instant access the moment you sign up.