Library › Computer Science 9618 › Artificial Intelligence (AI)
AS Level · Computer Science 9618

Artificial Intelligence (AI)

Revise Artificial Intelligence (AI) for Computer Science 9618 (AS Level) — revision notes and instant AI marking.

📖 Revision notes · preview
  Cambridge International AS & A Level Computer Science (9618)

Artificial Intelligence (AI)

The big idea: Many AI problems become "find the best path through a graph", which Dijkstra's algorithm and A* solve. Machine learning goes further: instead of being told the rules, the system learns them from data by adjusting the weights in a network until its errors are small.

Summary — What This Chapter Covers
  • A graph is a set of nodes (vertices) joined by edges, which may be weighted and directed. Graphs model routes, relationships, game states and neural networks.
  • Dijkstra's algorithm finds the shortest distance from a start node to every other node.
  • A* finds the shortest path to one goal using f = g + h, where h is a heuristic estimate of the remaining cost; it usually examines fewer nodes.
  • Artificial neural networks: input, hidden and output layers joined by weighted connections; training adjusts the weights.
  • Machine learning learns from data; deep learning uses networks with many hidden layers; reinforcement learning learns from rewards and penalties.
  • Supervised learning uses labelled data; unsupervised learning finds patterns in unlabelled data.
  • Back propagation sends the output error back through the network to adjust the weights; regression predicts a continuous value by fitting a function to data.
1. Graphs and Dijkstra's Algorithm
18.1

Shortest distance to every node

A graph is a collection of nodes (vertices) connected by edges. Edges may have a weight (distance, time, cost) and may be directed (one way). Graphs help AI because many problems can be stated as "move from one state to another at the lowest cost": road networks for route planning, positions in a game, links between people or web pages, and the structure of a neural network itself. Once a problem is a graph, search algorithms can solve it. (You are not asked to write code for graphs.)

Dijkstra's algorithm:

  1. Give the start node distance 0 and every other node ∞.
  2. Visit the unvisited node with the smallest distance.
  3. For each neighbour, calculate (distance of current node + edge weight). If this is smaller than the neighbour's recorded distance, replace it and record the current node as its previous node.
  4. Mark the current node visited; repeat from step 2 until every node is visited.
Worked Example
Edges (undirected): S–A 7, S–B 3, S–C 8, A–B 2, A–D 4, B–D 8, B–E 6, C–E 3, D–E 1, D–F 5, E–F 4. Use Dijkstra's algorithm to find the shortest distance from S to every node, and the route to F.
2. The A* Algorithm
18.1

Heuristics: f = g + h

A* searches for the shortest path to one particular goal. For each node it calculates

A* cost f = g + h    g = actual cost from the start to this node · h = heuristic: estimated cost from this node to the goal (for example straight-line distance)

It always expands the open node with the lowest f, updating g for neighbours when a cheaper route is found, and stops when the goal itself has the lowest f. Because h points the search towards the goal, A* usually examines far fewer nodes than Dijkstra. It is guaranteed to find the shortest path only if the heuristic never overestimates the true remaining cost. Dijkstra is the special case h = 0: it finds the shortest path to every node.

Worked Example
Practice Question
🔓 Read the full Artificial Intelligence (AI) note → You're seeing the preview · sign in to read it all
Also in the full note
  • ANNs, deep, machine and reinforcement learning
  • Adjusting weights, predicting values
What's inside
📖 Revision notes 🎯 Learn mode ✦ AI flashcards ✓ Instant AI marking 🧊 3D explorers 🧪 Experiments & simulations 📈 Progress tracking
📄 Practise Artificial Intelligence (AI) with Computer Science 9618 past papers Every paper with its mark scheme — answer online, marked instantly. Open →

Read the full Artificial Intelligence (AI) notes free

That's the preview — create a free account to read the rest, plus flashcards and practice questions with instant AI marking. No credit card.

Unlock the full notes free →

More Computer Science topics