impera Open Impera

IB Diploma Digital Society · Content

Algorithms

1What an algorithm is

An algorithm is a precise, step-by-step set of instructions for solving a problem or completing a task. A recipe is an everyday algorithm. In computing, algorithms are written as programs that computers follow exactly.

Good algorithms are:

  • Precise: each step is unambiguous.
  • Finite: they finish after a number of steps.
  • Effective: they solve the problem.
  • Efficient: they use as little time and memory as possible.

Algorithms are built from three basic structures: sequence (steps in order), selection (decisions: if this, then that) and iteration (repeating steps in loops).

Check yourself

What are the three basic structures of algorithms?

  • Input, cables and the screen

  • Start, stop and pause controls

  • Hardware, software and data

  • Sequence, selection and iteration

Show the answer

Sequence, selection and iteration

Steps, decisions, loops.

2Representing algorithms

Algorithms can be shown as:

  • Flowcharts: diagrams using standard shapes (ovals for start and end, rectangles for processes, diamonds for decisions).
  • Pseudocode: structured plain-language steps.
  • Code: in a programming language such as Python.
Worked example

An algorithm to decide whether a student passes

  1. Start.
  2. Input the student's score.
  3. If the score is 50 or more, output "Pass"; otherwise output "Not yet".
  4. End.

Even this simple algorithm embeds a value judgement: who decided that 50 is the threshold, and is it fair?

A simple algorithm as a flowchart: who chose 50 as the threshold?

Check yourself

Which flowchart shape represents a decision?

  • An oval

  • A diamond

  • A rectangle

  • A circle

Show the answer

A diamond

Yes or no branches.

3Algorithms in society

Algorithms shape daily life:

  • Search engines rank web pages. Google's original PageRank (1998) ranked pages partly by how many other pages linked to them.
  • Recommendation algorithms on streaming and social media suggest content based on past behaviour and similar users.
  • Navigation apps calculate the fastest routes.
  • Automated decision-making: credit scores, hiring filters, insurance prices, welfare fraud detection and policing.
  • Algorithmic trading buys and sells shares in fractions of a second.

Many modern algorithms use machine learning: instead of following rules written by humans, they learn patterns from data, which can make them harder to explain.

Check yourself

What do recommendation algorithms use to suggest content?

  • The current weather in the user's location

  • Only the newest content uploaded to the site

  • Random choices made without any user data

  • Users' past behaviour and that of similar users

Show the answer

Users' past behaviour and that of similar users

Personalization.

4Algorithmic bias and accountability

Algorithms can produce unfair outcomes:

  • Biased training data: Amazon reportedly abandoned an experimental hiring tool around 2018 after it was found to downgrade CVs that included the word "women's".
  • Proxy discrimination: even without using protected characteristics directly, algorithms may use postcodes or other data that correlate with race or income.
  • The black box problem: complex models can be hard to explain, even to their designers.

In 2020, the UK used an algorithm to award A-level grades after exams were cancelled. It downgraded many teachers' predictions and appeared to disadvantage students from historically lower-performing schools. After protests ("Ditch the algorithm"), the government reverted to teacher-assessed grades.

Responses: algorithmic audits, explainable AI, human review, and laws giving people rights regarding automated decisions (GDPR Article 22).

Check yourself

What happened with the UK's 2020 A-level grading algorithm?

  • It was designed but never actually used to award any grades

  • It gave every student the top grade in every subject they took

  • It seemed to disadvantage students at weaker schools and was abandoned

  • It was praised by students, teachers and parents across the country

Show the answer

It seemed to disadvantage students at weaker schools and was abandoned

"Ditch the algorithm".

5Filter bubbles and amplification

  • Eli Pariser (2011) described filter bubbles: personalized algorithms show users content that matches their views, potentially isolating them from other perspectives. Research suggests the effect is real but often smaller than feared.
  • Engagement-based ranking can amplify sensational, emotional or divisive content because it attracts clicks and shares.
Check yourself

Who coined the term filter bubble?

  • Eli Pariser

  • Larry Page

  • Alan Turing

  • Tim Berners-Lee

Show the answer

Eli Pariser

2011.

6Efficiency and complexity

Algorithms differ in efficiency: how much time and memory they need.

  • Linear search checks each item in turn.
  • Binary search halves a sorted list each step, so it is much faster for large lists.
  • Big O notation describes how running time grows: O(n) for linear search, O(log n) for binary search.

Efficiency matters at scale: a search engine handles billions of queries.

Check yourself

Why is binary search faster than linear search on large sorted lists?

  • It checks every item twice

  • It uses more memory

  • It halves the list each step

  • It works on unsorted lists only

Show the answer

It halves the list each step

O(log n).

7Recommendation algorithms

Recommendation algorithms suggest content based on data.

  • Collaborative filtering: recommends items liked by similar users.
  • Content-based filtering: recommends items similar to ones you liked.
  • Platforms optimise for engagement, measured by clicks and watch time.
Worked example

A recommendation loop

  1. A user watches several cooking videos.
  2. The algorithm recommends more cooking videos.
  3. The user watches them, confirming the pattern.
  4. Result: the user's feed narrows, an example of a filter bubble.
Check yourself

What is collaborative filtering?

  • Recommending items liked by similar users

  • Removing illegal content from websites

  • Filtering spam messages out of email inboxes

  • Recommending items that are chosen at random

Show the answer

Recommending items liked by similar users

Similar users.

8Going deeper: two real cases of algorithms making decisions about people

In Digital Society you are expected to analyse real-world examples for their impacts and implications for people and communities. These two cases are well documented and raise different issues.

Case 1: A risk score in criminal courts (COMPAS, United States)

  • COMPAS is commercial software that gives defendants a score for the risk of reoffending, which judges may consult in decisions on bail and sentencing.
  • In 2016 the news organisation ProPublica analysed scores for about 7,000 people in one Florida county. Among those who did not go on to reoffend, Black defendants were almost twice as likely as white defendants to have been labelled high risk.
  • The company replied that the score was equally accurate for both groups: among people given the same score, similar proportions reoffended.
  • Researchers then showed that both statements can be true, and that when two groups have different underlying rates in the data, it is mathematically impossible to satisfy both definitions of fairness at once.
  • What this shows: "fair" has more than one meaning, and choosing between them is a value judgement that the software's designers make, often without public debate. The data also reflect past policing, so historic bias is carried forward.
  • Accountability and transparency: the formula is a trade secret. A defendant challenged this in State v. Loomis (Wisconsin, 2016) and lost, though the court warned judges about the tool's limits.

Case 2: Grading by algorithm (United Kingdom, 2020)

  • When examinations were cancelled in the pandemic, the regulator used an algorithm to adjust teachers' predicted grades, partly according to each school's results in earlier years.
  • About 40% of teacher-assessed A-level grades were lowered. Able students at schools with weaker past results were marked down, while small classes, more common in private schools, were adjusted less.
  • After protests, the government abandoned the algorithm and used teachers' grades.
  • What this shows: a model that is accurate on average can be unjust to individuals; using group history to judge a person entrenches inequality; and people need a way to challenge an automated decision.

Questions to ask of any algorithm

  1. What data was it built from, and whose experience is missing or distorted?
  2. Which measure of success was chosen, and by whom?
  3. Who benefits and who bears the cost of errors?
  4. Can the decision be explained to the person affected?
  5. Is there a human who can review it, and a way to appeal?

Responses

  • Regulation: the EU's GDPR gives people rights concerning solely automated decisions with significant effects; the EU AI Act (2024) classes uses such as hiring, credit and policing as high risk, with duties of testing and oversight.
  • Audits of algorithms by independent bodies.
  • Explainable AI and a "human in the loop" for serious decisions.
  • Diverse design teams and consultation with affected communities.
Check yourself

What did the debate over the COMPAS risk score show about fairness?

  • Algorithms are always fairer than human judges, because they apply the same rules to everyone

  • Different mathematical definitions of fairness can conflict, so choosing one is a value judgement

  • The scores were accurate for no group at all, so risk scores should never be used in courts

  • Fairness can be achieved simply by removing race from the data, so the problem is now solved

Show the answer

Different mathematical definitions of fairness can conflict, so choosing one is a value judgement

Equal accuracy across groups and equal error rates cannot both hold when underlying rates differ.

Now test yourself

This lesson has a 8-question quiz and 4 exam-style questions with mark schemes in Impera. Free, with your progress saved.

Practise in Impera