18 Artificial intelligence and machine learning
Use graph searches to find paths and compare machine-learning approaches, data and evaluation limits.
Mapped to Cambridge International AS & A Level Computer Science 9618, 2027–2029 Version 2. These original lessons and self-checks are independent study support; they are not Cambridge papers, official marks or grades. The course does not yet provide a timed four-paper simulation or a locked-down Paper 4 programming environment.
Before you begin
- Use the 2027–2029 syllabus for your exam year. AS candidates study Sections 1–12; A Level candidates study Sections 1–20. Paper 4 uses a programming language chosen from Python, Java or Visual Basic in console mode.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
What does an edge weight represent in a route graph?
What you will learn
- Explain the key representations, structures or processes in this syllabus section
- Apply the method to a new computer-science example
- Justify a design choice and check its limits
Graphs model connected states
A graph has vertices and edges; edges may have weights. A* uses a path cost so far plus a heuristic estimate to guide search toward a goal. Dijkstra's algorithm finds least-cost paths when edge weights are non-negative.
The heuristic in A* should not overestimate the remaining cost when optimality is required. Both algorithms need the graph, start and goal; their results depend on weights and assumptions. Learners are expected to use these searches on a graph, not write graph setup or search code for this section.
Learning categories use data and feedback differently
Supervised learning uses labelled examples; unsupervised learning looks for structure without target labels; reinforcement learning learns through actions and reward signals. Neural networks adjust connected weights from data; deep learning uses networks with multiple layers.
Machine learning may improve recognition or prediction but can inherit bias, overfit, expose private data or require substantial energy. Evaluate training data, test data, error costs and human oversight. A high score on one test set does not guarantee performance in every real setting.
Pause and explain
What is a heuristic in A* search?
Worked example
A navigation graph has edges of non-negative travel time. Which method finds a shortest route without a heuristic, and what can A* add?
Show the worked solution
- Dijkstra's algorithm uses known path costs.
- A* adds a heuristic estimate from each node to the goal.
- A suitable non-overestimating heuristic can guide search while preserving an optimal path.
Answer Dijkstra uses accumulated cost; A* also uses a heuristic estimate to guide exploration.
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
A route graph has non-negative edge weights. Explain how Dijkstra's algorithm chooses which unvisited node to process next.
Give me a hint
Track tentative total distance from the start.
Compare my reasoning
- For each unvisited node, keep the best known distance from the start.
- Choose the unvisited node with the smallest tentative distance.
- Relax its outgoing edges and update any shorter routes.
Process the unvisited node with the lowest tentative distance, then update neighbours.
Look for these in your work
- Tentative distances used
- Minimum selected
- Neighbour updates explained
A model is trained to identify faulty components from labelled sensor readings. Name the learning category and one evaluation risk.
Give me a hint
The training examples include the expected class.
Compare my reasoning
- This is supervised learning because labels identify faulty or normal components.
- A risk is that the test set does not represent real operating conditions.
- Evaluate errors on separate representative data and consider the cost of missed faults.
Supervised learning; a non-representative test set can hide poor real-world performance.
Look for these in your work
- Category correct
- Evaluation risk stated
- Appropriate response
A data set for loan prediction underrepresents one region. Explain how this can affect an AI system and propose two safeguards.
Give me a hint
Consider performance gaps and consequences for affected applicants.
Compare my reasoning
- The model may have higher error rates for people from the underrepresented region.
- Audit results across groups and collect representative, lawfully obtained data.
- Keep human review and a way to challenge consequential decisions.
Underrepresentation can create unequal errors; use representative data, subgroup audits and review/appeals.
Look for these in your work
- Effect explained
- Two safeguards
- Impact-aware review
Common mistakes
- Using Dijkstra's algorithm with negative edge weights.
- Calling all neural networks deep learning regardless of layer structure.
- Treating a reward signal as a guaranteed correct label.
What can you explain now?
Which learning approach uses labelled input-output examples?
Compare with the explanation
Supervised learning
The examples include target labels used to train and evaluate predictions.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
How do A* and Dijkstra use graph costs, and how do supervised, unsupervised and reinforcement learning differ?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.