Skip to content
Cambridge AS & A Level9618

Artificial Intelligence (AI)

Computer Science 9618 Chapter Notes

Last updated November 2026

ShareWhatsAppPost

Artificial Intelligence (AI) notes as a printable PDF.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Artificial Intelligence (AI) notes as text: skim, search, and jump between subtopics.

~13 min read

1. Graphs in AI

A graph is used in AI to record relationships between entities. It is made of vertices / nodes and edges.

A node can represent a place, a person or a destination. An edge connects two nodes and can represent a possible path between them. Nodes and edges can be labelled or weighted, such as a distance on a map.

Examiner insight

“Many different answers were seen, for example, candidates recognised the use of graphs in Artificial Intelligence for Artificial Neural Networks, relationships, or connections between nodes, or in a range of methods such as back propagation of errors.”

Worked example 12 marks

Describe the structure of a graph as used in an Artificial Intelligence (AI) system.

  1. 1

    a graph uses vertices / nodes to represent entities such as destinations, people [1]

  2. 2

    edges connect nodes and can represent possible paths between them; they can be labelled / weighted [1]

2. Dijkstra's algorithm

Dijkstra's algorithm finds the shortest path from a start node to every other node on a weighted graph. Set the start node to 0 and every other node to ∞.

Take the unvisited node with the smallest value and mark it visited. Work out the route to each neighbour through it. If the new total is smaller, update the neighbour. Repeat until every node is visited. Show the working.

Examiner insight

“A small number of candidates demonstrated more detailed use of Dijkstra’s algorithm, by showing other evidence, such as initially setting the Base to 0, the other towns to ∞, or clearly identifying ‘visited nodes’.”

Worked example 15 marks

Calculate the shortest distance from node S to each of the other nodes using Dijkstra's algorithm. Show your working. The edges and their weights are given in the table.

EdgeS–AS–BB–AA–CB–CB–DC–DC–ED–E
Weight4215810263
  1. 1

    start: S = 0 and A, B, C, D, E = ∞ [1]

  2. 2

    visit S: B = 2, A = 4; visit B (2): A = 2 + 1 = 3 replaces 4, C = 10, D = 12 [1]

  3. 3

    visit A (3): C = 3 + 5 = 8 replaces 10; visit C (8): D = 8 + 2 = 10 replaces 12, E = 14; visit D (10): E = 10 + 3 = 13 replaces 14 [1]

  4. 4

    answers: A = 3, B = 2, C = 8, D = 10, E = 13: four correct values [1]

  5. 5

    all five values correct [1]

3. A* compared with Dijkstra's

Both algorithms find the path between two points on a graph. A* tries to find a better path by using a heuristic function.

The heuristic gives priority to nodes that are supposed to be better, or less costly, than others. A* picks the node with the smallest total f.

Dijkstra's algorithm just explores all possible routes, so it always finds the shortest path. A* may not find the shortest path if its heuristics are inaccurate.

f = g + h

Worked example 12 marks

Outline the difference between the A* and Dijkstra’s algorithms.

  1. 1

    A* tries to find a better path by using a heuristic function [1]

  2. 2

    Dijkstra’s just explores all possible routes [1]

4. Artificial neural networks and deep learning

An artificial neural network simulates the functioning of a biological brain. It is a key component of machine learning.

It is built in layers: input, hidden and output. Weights are assigned between nodes. Training adjusts the weights to give a more accurate result.

Deep learning is a branch of machine learning that makes use of artificial neural networks with many hidden layers. It finds hidden patterns in large data sets.

Examiner insight

“Most candidates achieved at least one mark, usually for recognising how an ANN is modelled on a biological brain.” “Some candidates gave answers that would be better placed in part (a), because they described what deep learning is rather than reasons it would be used.”

Worked example 14 marks

Artificial neural networks have played a significant role in the development of machine learning. Explain what is meant by the term artificial neural network.

  1. 1

    the component of AI meant to simulate the functioning of a biological brain [1]

  2. 2

    layered: input, hidden and output layers [1]

  3. 3

    weights are assigned between nodes [1]

  4. 4

    weights are adjusted through training to give a more accurate result [1]

5. Supervised and unsupervised learning

Supervised learning uses labelled input data: known inputs with their associated outputs. It can predict future outcomes from past data.

Unsupervised learning needs only input data. It uses unlabelled data and finds unknown patterns, groupings or clusters without human intervention.

Examiner insight

“The majority of answers that gained credit did so for identifying the use of labelled input data for supervised learning and/or the use of unlabelled data for unsupervised learning, either in these terms or as descriptions.”

Worked example 14 marks

Supervised and unsupervised learning are two categories of machine learning. Describe supervised learning and unsupervised learning.

  1. 1

    supervised: known inputs and associated outputs are given // uses labelled input data [1]

  2. 2

    supervised: able to predict future outcomes based on past data [1]

  3. 3

    unsupervised: only requires input data // uses unlabelled input data [1]

  4. 4

    unsupervised: helps unknown patterns in data to be found [1]

6. Reinforcement learning

Reinforcement learning is a machine learning technique based on feedback: rewards and punishments.

An agent learns to behave in an environment by performing actions and seeing the results. A good action earns a reward. A bad action earns a punishment. It learns without labelled data.

Worked example 13 marks

Explain what is meant by Reinforcement Learning in relation to Artificial Intelligence.

  1. 1

    a machine learning technique based on feedback / rewards / punishment [1]

  2. 2

    an agent learns to behave in an environment by performing the actions and seeing the results of the actions [1]

  3. 3

    each good action gets positive feedback / reward and each bad action gets negative feedback / punishment [1]

7. Back propagation and regression

Back propagation of errors compares the network's initial outputs with the expected outputs. The results are fed back into the neural network and the weightings are adjusted to minimise the difference. The process repeats until the results are more accurate.

Regression is a supervised learning technique. It finds a mathematical function, or a best-fit line / curve, that maps how independent variables influence a dependent variable. It is used for forecasting trends and predicting outcomes. It is trained to understand the relationship between different causes and effects.

Its goal is to minimise the difference between the predicted values and the actual values.

Worked example 13 marks

Explain what is meant by regression methods in relation to machine learning.

  1. 1

    a supervised learning technique of machine learning [1]

  2. 2

    it finds a mathematical function // plots a best-fit line / curve [1]

  3. 3

    that maps how independent variables / causes influence a dependent variable / effect [1]

Recap

  • Graph: nodes represent entities; edges connect them and can be weighted. Dijkstra's: start = 0, others = ∞; update to smaller totals; mark visited.
  • A* adds a heuristic: f = g + h. Dijkstra's explores all routes and always finds the shortest.
  • Neural network: layers joined by weights adjusted in training. Deep learning: many hidden layers; finds hidden patterns.
  • Supervised = labelled data. Unsupervised = unlabelled data. Reinforcement = rewards and punishments.
  • Back propagation adjusts weightings from the errors. Regression fits a best-fit line to predict outcomes.

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. A map of towns and roads is stored as a graph in an AI system. State what a town, a road and the length of a road are represented by in the graph.3 marks
    Answer
    1. A town is a node / vertex [1].
    2. A road is an edge [1].
    3. The length is a weight on the edge [1].

    Trap: Swapping nodes and edges: the nodes are the towns, the edges are the roads.

  2. State the purpose of the A* and Dijkstra’s algorithms. Then state what the heuristic does in A*.2 marks
    Answer
    1. They find the optimum / shortest path between two nodes on a graph [1].
    2. The heuristic gives priority to nodes that are supposed to be better, or less costly, than others [1].

    Trap: Describing how the algorithm works step by step when the question asks for its purpose.

  3. In A*, f = g + h. From the start node, three nodes can be reached. Node X has g = 4 and h = 6. Node Y has g = 7 and h = 5. Node Z has g = 3 and h = 11. Which node does A* explore next?2 marks
    Answer
    1. f_X = 4 + 6 = 10, f_Y = 7 + 5 = 12, f_Z = 3 + 11 = 14.
    2. The smallest total is X, so A* explores X next [2].

    Trap: Choosing by the smallest h (Y) or the smallest g (Z) instead of the smallest f = g + h.

  4. Describe the structure of an artificial neural network and how back propagation of errors improves its results as it is trained.4 marks
    Answer
    1. It has layers: an input layer, hidden layers and an output layer [1].
    2. Weights are assigned between nodes [1].
    3. Initial outputs are compared with the expected outputs, and the results are fed back into the network [1].
    4. The weightings are adjusted to minimise the difference, and the process repeats until the results are more accurate [1].

    Trap: Saying the nodes are changed in training: it is the weightings between nodes that are adjusted.

  5. Give two reasons for using deep learning.2 marks
    Answer
    1. It finds hidden patterns that are undetectable to humans / too complex or time consuming for humans to process [1].
    2. It works well with large data sets [1].

    Trap: Describing what deep learning is (layers, neural networks) when the question asks for reasons to use it.

  6. A bank has 10 000 past transactions, each marked “fraud” or “not fraud”. State the machine learning category that learns from this data and why. A second bank has transactions with no marks and wants to find groups of similar ones. State the category it uses.3 marks
    Answer
    1. Supervised learning [1].
    2. It uses labelled data: known inputs with their outputs [1].
    3. The second bank uses unsupervised learning, which finds hidden patterns / clusters in unlabelled data [1].

    Trap: Swapping the categories: marked data is labelled, so it is supervised.

  7. A program learns to play a game. It gets +1 for each win and −1 for each loss. State the category of machine learning and explain how the +1 and −1 are used.3 marks
    Answer
    1. Reinforcement learning [1].
    2. The +1 is a reward / positive feedback for a good action and the −1 is a punishment / negative feedback for a bad action [1].
    3. The agent learns by performing actions and seeing the results, without labelled data [1].

    Trap: Calling it supervised learning because there is feedback: no labelled input–output pairs are given.

  8. A model is trained on past data to forecast the price of a house from its floor area, using a best-fit line. Name this machine learning method, state the category it belongs to, and state what training tries to minimise.3 marks
    Answer
    1. Regression [1].
    2. It is a supervised learning technique [1].
    3. Training minimises the difference between the predicted values and the actual values [1].

    Trap: Calling regression unsupervised because it finds a pattern: it learns from past data with known outcomes (prices), so it is supervised.

  9. A delivery network has edges D–A = 6, D–B = 3, B–A = 2, A–C = 4, B–C = 7, B–E = 9, C–E = 1, C–F = 8 and E–F = 3. Use Dijkstra's algorithm to find the shortest distance from D to every other node. Show your working, then state the route to F.6 marks
    Answer
    1. Start: D = 0, all others = ∞ [1].
    2. Visit D: A = 6, B = 3. Visit B (3): A = 3 + 2 = 5 replaces 6; C = 10; E = 12. Visit A (5): C = 5 + 4 = 9 replaces 10 [1].
    3. Visit C (9): E = 9 + 1 = 10 replaces 12; F = 17. Visit E (10): F = 10 + 3 = 13 replaces 17. Visit F [1].
    4. A = 5, B = 3, C = 9, E = 10, F = 13 [2].
    5. The route to F is D–B–A–C–E–F: 3 + 2 + 4 + 1 + 3 = 13 [1].

    Trap: Stopping at the first route found to a node: A = 6, C = 10, E = 12 and F = 17 are all replaced by shorter routes.

  10. A warehouse robot plans a route from S to G with the A* algorithm. The edges and their weights are S–A = 4, S–B = 5, A–C = 6, B–C = 2, B–D = 7, B–G = 9, C–G = 5 and D–G = 2. The heuristic h of each node is given in the table. Find the best path from S to G. Show your working as rows of current path, destination node, g, h and f = g + h. The first two rows are S, S, 0, 10, 10 and S, A, 4, 9, 13. | Node | S | A | B | C | D | G | | --- | --- | --- | --- | --- | --- | --- | | h | 10 | 9 | 6 | 4 | 2 | 0 |5 marks
    Answer
    1. S to B: g = 5, h = 6, f = 11 [1].
    2. B has the smallest f, so expand B. S–B to C: g = 5 + 2 = 7, f = 11. S–B to D: g = 5 + 7 = 12, f = 14. S–B to G: g = 5 + 9 = 14, f = 14 [1].
    3. C has the smallest f (11), so expand C. S–B–C to G: g = 5 + 2 + 5 = 12, h = 0, f = 12 [1].
    4. G now has the smallest f (12, below A = 13 and D = 14), so the search stops [1].
    5. Final path S–B–C–G, cost 12 [1].

    Trap: Giving S–B–G (14) because G first appeared there, or giving the final path without the rows of working that earn most of the marks.

Say this, not that

Wording that loses the mark, against the wording the mark scheme credits.

Loses the markGets the mark
Deep learning uses a neural network with many layers. (given as the reason for using it)Used to find hidden patterns that are too complex or time consuming for humans to process.
A* final path only: Begin, C, G, F, End.Every row of the table: g, h and f = g + h for each node, then the final path.
Dijkstra's: the final distances only.Start = 0, the rest ∞, values updated and visited nodes shown, then the distances.

Frequently asked questions

What is a graph in artificial intelligence?
A graph records relationships between entities. It is made of vertices, also called nodes, and edges. A node can represent a place, a person or a destination, and an edge connects two nodes and can represent a possible path between them. Nodes and edges can be labelled or weighted, such as a distance on a map.
How does Dijkstra's algorithm find the shortest path?
Dijkstra's algorithm finds the shortest path from a start node to every other node on a weighted graph. Set the start node to 0 and every other node to infinity. Take the unvisited node with the smallest value, mark it visited, and update any neighbour if the new total is smaller. Repeat until every node is visited, and show the working.
How is the A* algorithm different from Dijkstra's algorithm?
Both algorithms find a path between two points on a graph. A* uses a heuristic function, f = g + h, to give priority to nodes that are supposed to be better, and it picks the node with the smallest total f. Dijkstra's algorithm explores all possible routes, so it always finds the shortest path, while A* may not if its heuristics are inaccurate.
What is an artificial neural network and how is it trained?
An artificial neural network simulates the functioning of a biological brain and is a key component of machine learning. It is built in layers: input, hidden and output, with weights assigned between nodes. Back propagation of errors compares the outputs with the expected outputs and adjusts the weightings to minimise the difference, repeating until the results are more accurate.
What is the difference between supervised and unsupervised learning?
Supervised learning uses labelled input data, with known inputs and their associated outputs, and can predict future outcomes from past data. Unsupervised learning needs only input data. It uses unlabelled data and finds unknown patterns, groupings or clusters without human intervention.
Why do I lose marks when I give only the final path in Dijkstra's algorithm?
Some candidates gave the final path without showing a fully complete set of working. Show the start node set to 0 and the rest set to infinity, the values updated and the visited nodes, then the distances.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters