Artificial Intelligence is defined as the capability of a computer or a robot controlled by a computer to perform tasks that typically require human intelligence. These tasks include reasoning, discovering meaning, generalizing, or learning from past experiences!
1. AI & Graphs
In Artificial Intelligence, graphs are fundamental data structures used to model relationships, networks, and decision-making problems. A graph is a set of vertices/nodes connected by edges/arcs.
1.1 What Can Graphs Represent in AI?
📖 Graph Applications in AI
Routes between cities - pathfinding algorithms
Connections in neural networks - deep learning structures
State transitions - decision trees and planning
Game boards - AI game playing
Map-based navigation - GPS systems
Social networks - connection analysis
1.2 Types of Graphs
Graph Type
Use in AI
Directed Graph
Models one-way relationships, such as state transitions in search algorithms (e.g. A*)
Undirected Graph
Useful for bidirectional relationships, such as undirected social connections
Weighted Graph
Represents costs or heuristics, commonly used in shortest path algorithms like Dijkstra's or A*
1.3 Graph Representation
Graphs can be represented using two main methods:
📝 Graph Representation Methods
Adjacency Matrix: Ideal for dense graphs and fast lookup - uses 2D array where matrix[i][j] = 1 if edge exists
Adjacency List: More space-efficient for sparse graphs (often used in AI search) - stores list of neighbours for each node
💡 Exam Tip
Remember: Adjacency Matrix = O(n²) space but O(1) edge lookup. Adjacency List = O(V+E) space, better for sparse graphs!
2. Undirected, Unweighted Graphs
An undirected, unweighted graph is a type of graph where edges have no direction (connections go both ways) and all edges are equal (there are no weights or costs).
📖 Key Characteristics
Edges have no direction - connections go both ways
All edges are equal - no weights or costs
Represented with a symmetric adjacency matrix
A 1 indicates a connection exists, 0 means no connection
2.1 AI Relevance
Undirected, unweighted graphs are useful in AI for:
Use Case
Description
Exploring environments
Mapping rooms in a building with equal-cost connections
Clustering in ML
Presence of a connection implies similarity
Social network analysis
Mutual connections (friendships, links) are undirected
Graph traversal
Depth-first or breadth-first search to explore all reachable nodes
Example: Each node represents a town (e.g., Bolton, Dunkirk, Teesside). A 1 in the matrix shows a connection exists between two towns. A 0 means no direct connection. The matrix is symmetric, confirming that the graph is undirected.
3. Directed Graphs & Weighted Graphs
3.1 Directed Graph (Digraph)
A directed graph is one where edges have a direction. This means connections go from one node to another. Connections cannot be traversed in reverse unless another directed edge exists.
⚠️ Key Points
Arrows show the direction of travel
A 1 at (row X, column Y) means there is a directed edge from X to Y
The matrix is NOT symmetric - reflects one-way nature
3.2 Directed Graph AI Applications
Use Case
How the Graph is Used
Search algorithms
Used in A*, BFS, DFS where state transitions are directional
Expert systems/rule engines
Representing dependencies between logical conditions or actions
Planning and scheduling
Modelling prerequisites and directed workflows
Navigation
Handling one-way streets or directed transport systems
3.3 Undirected, Weighted Graphs
An undirected, weighted graph is a graph where edges go both ways (no direction) but each edge has a weight, which can represent cost, distance, time, or risk.
📖 Weight Representation
If no connection exists between two nodes, the matrix contains ∞ (infinity)
Weights can represent: distance, cost, time, risk
The matrix is symmetric for undirected graphs
3.4 Directed, Weighted Graphs
A directed, weighted graph combines both direction and weights. Edges have a direction (e.g., A → B but not B → A) and each edge has a weight such as distance, cost, time, or probability.
Use Case
Purpose in AI
A* and Dijkstra algorithms
Choosing the shortest path where direction and cost matter
Modelling rewards/costs for state transitions in decision environments
Game AI
Movement systems with terrain costs or restrictions
4. Dijkstra's Shortest Path Algorithm
In Computer Science, an optimisation problem involves finding the most efficient solution to a given problem. This could mean minimising cost, time, or resource usage, or maximising output, efficiency, or value.
4.1 What is Dijkstra's Algorithm?
Dijkstra's shortest path algorithm is a classic optimisation algorithm that calculates the shortest path from a starting node to all other nodes in a weighted graph.
📖 How Dijkstra's Works
The graph is made up of nodes (vertices) and edges (arcs)
Each edge has a weight representing time, distance, or cost
The algorithm explores all possible routes, keeping track of the shortest known distance to each node
It guarantees the optimal path from the start node to every other node
Works by repeatedly selecting the nearest unprocessed node and performing relaxation on all its edges
4.2 Algorithm Steps
📝 Dijkstra's Algorithm Procedure
Set the start node's path weight to 0 and all other path weights to infinity
Mark all nodes as unvisited
Visit the node with the lowest path weight
For each neighbour, calculate the new path weight through current node
If new weight is less than current weight, update it
Mark current node as visited
Repeat steps 3-6 until all nodes visited or goal reached
Backtrack from goal to find the shortest path
Real-World Example: In a city road map (graph where intersections are nodes), Dijkstra's algorithm helps to find the shortest path from home (source node) to a destination like a coffee shop.
4. Dijkstra's Algorithm (Continued)
4.3 Pseudocode
FUNCTION Dijkstra(graph, start, goal)
// Initialise distances
FOR EACH node FROM graph
SET distance[node] TO infinity
NEXT node
SET distance[start] TO 0
DECLARE previousNode AS DICTIONARY
DECLARE visited AS LIST
DECLARE unvisited AS LIST
FOR EACH node FROM graph
ADD node TO unvisited
NEXT node
WHILE LENGTH(unvisited) > 0
// Find unvisited node with shortest distance
SET min TO null
FOR EACH node FROM unvisited
IF min = null THEN
SET min TO node
ELSEIF distance[node] < distance[min] THEN
SET min TO node
ENDIF
NEXT node
// Exit if goal reached
IF min = goal THEN
EXIT WHILE
ENDIF
// Update distances to neighbours
FOR EACH neighbour FROM graph[min]
SET cost TO weight(min, neighbour)
SET alt TO distance[min] + cost
IF alt < distance[neighbour] THEN
SET distance[neighbour] TO alt
SET previousNode[neighbour] TO min
ENDIF
NEXT neighbour
REMOVE min FROM unvisited
ADD min TO visited
ENDWHILE
// Build path from goal to start
DECLARE path AS LIST
SET node TO goal
WHILE node != start
ADD node TO path
SET node TO previousNode[node]
ENDWHILE
ADD start TO path
REVERSE path
RETURN path
ENDFUNCTION
4.4 Python Implementation
def dijkstra(graph, start, goal):
# Initialise distances and previous node map
distance = {node: float('inf') for node in graph}
distance[start] = 0
previous_node = {}
visited = set()
unvisited = set(graph.keys())
while unvisited:
# Find the unvisited node with smallest distance
min_node = None
for node in unvisited:
if min_node is None or distance[node] < distance[min_node]:
min_node = node
if min_node == goal:
break
for neighbour, weight in graph[min_node]:
if neighbour in visited:
continue
alt = distance[min_node] + weight
if alt < distance[neighbour]:
distance[neighbour] = alt
previous_node[neighbour] = min_node
visited.add(min_node)
unvisited.remove(min_node)
# Reconstruct path from goal to start
path = []
current = goal
while current != start:
path.append(current)
current = previous_node[current]
path.append(start)
path.reverse()
return path
💡 Exam Tip
Key assumptions in pseudocode: graph[node] returns a list of neighbour nodes, weight(x, y) returns the edge weight between nodes x and y. Lists support ADD and REMOVE operations.
5. A* Algorithm
The A* (A-star) algorithm is a pathfinding algorithm that builds upon Dijkstra's algorithm by introducing a heuristic function to improve efficiency.
5.1 How A* Improves on Dijkstra's
📖 Key Improvements
Dijkstra's considers only the actual cost from the start node
A* enhances this by estimating the remaining distance to the goal
This makes it more goal-oriented and often more efficient
Avoids inefficient detours by using the heuristic function h(x)
5.2 The A* Formula
f(x) = g(x) + h(x)
Term
Meaning
g(x)
The actual cost from the start node to the current node
h(x)
The heuristic estimate to the goal node (e.g., straight-line distance)
f(x)
The total estimated cost of the cheapest solution through node x
5.3 Heuristics in A*
⚠️ Important: Heuristic Rules
The heuristic function h(x) should never overestimate the true cost to the goal
This ensures A* remains optimally efficient
The closer h(x) is to the true cost, the fewer nodes A* needs to explore
If h(x) increases, it may indicate the algorithm is moving away from the goal
Common heuristic: Euclidean distance (straight-line distance) to goal
Example: For a GPS navigation system (using a graph where locations are nodes), A* might use straight-line distance to the destination as a heuristic to suggest quicker routes.
5. A* Algorithm (Continued)
5.4 A* vs Dijkstra's Comparison
Feature
Dijkstra's
A* Search
Goal-aware?
No
Yes
Cost function
g(x) only
g(x) + h(x)
Speed
Slower (explores more nodes)
Faster (more direct toward goal)
Use of heuristic
None
Yes, estimates distance to goal
Best for...
Full shortest path map
Fastest route to a specific destination
5.5 A* Pseudocode
FUNCTION AStarSearch(graph, start, goal)
// Initialise distances and f-scores
FOR EACH node FROM graph
SET g[node] TO infinity
SET f[node] TO infinity
NEXT node
SET g[start] TO 0
SET f[start] TO h[start]
DECLARE openSet AS LIST
ADD start TO openSet
WHILE openSet IS NOT EMPTY
// Find node in openSet with the lowest f value
SET min TO null
FOR EACH node FROM openSet
IF min = null THEN
SET min TO node
ELSEIF f[node] < f[min] THEN
SET min TO node
ENDIF
NEXT node
IF min = goal THEN
EXIT WHILE
ENDIF
REMOVE min FROM openSet
// Check all neighbours of current node
FOR EACH neighbour FROM graph[min]
SET tentativeG TO g[min] + cost(min, neighbour)
IF tentativeG < g[neighbour] THEN
SET g[neighbour] TO tentativeG
SET f[neighbour] TO g[neighbour] + h[neighbour]
SET previousNode[neighbour] TO min
IF neighbour NOT IN openSet THEN
ADD neighbour TO openSet
ENDIF
ENDIF
NEXT neighbour
ENDWHILE
// Build path from goal to start
DECLARE path AS LIST
SET node TO goal
WHILE node != start
ADD node TO path
SET node TO previousNode[node]
ENDWHILE
ADD start TO path
REVERSE path
RETURN path
ENDFUNCTION
💡 Exam Tip
Key assumptions: graph[node] returns adjacency lists, h[node] is your heuristic table, g[] and f[] are maps for real cost and estimated total cost.
🧠 Memory Trick
Remember the A* formula: f(x) = g(x) + h(x)
g = gone (cost you've already traveled)
h = hope (estimated cost remaining)
f = future (total estimated cost)
6. Machine Learning
Machine learning is a subset of AI where algorithms are trained to learn from and make predictions or decisions based on past data (experience).
📖 What is Machine Learning?
A type of artificial intelligence that allows computers to learn patterns from data
Improves performance without being explicitly programmed
Instead of following fixed rules, ML systems analyse data, identify patterns, and make predictions
Used in: spam filters, voice assistants, recommendation systems, fraud detection
6.1 Categories of Machine Learning
Machine learning algorithms are categorised based on how they learn from data:
Category
Description
Example
Supervised Learning
Trained on labelled data with known outputs
Spam filter, face recognition
Unsupervised Learning
Works with unlabelled data to find patterns
Customer segmentation
Reinforcement Learning
Learns by trial and error with rewards/penalties
Game AI, robotics
Example: A machine learning model may learn to identify fruits from images by analyzing many examples of fruits, similar to how a baby learns to recognize objects by looking at them repeatedly.
7. Types of Machine Learning
7.1 Supervised Learning
Supervised learning involves training a model on a labelled dataset, where the desired outcomes are known. The model learns to map input data to known outputs, effectively learning by example.
📖 Supervised Learning Characteristics
Trained on data with known outputs (labels)
Learns to map inputs to correct outputs
Can predict future outcomes based on past data
Used for classification (categorical output) and regression (continuous output)
Example: A spam filter is trained with emails labelled as 'spam' or 'not spam'. The program uses this training to improve its ability to classify new emails correctly.
7.2 Unsupervised Learning
Unsupervised learning works with datasets without labelled outcomes. The goal is to find patterns or intrinsic structures within the data.
📖 Unsupervised Learning Characteristics
Only requires input data (no labels)
Finds unknown patterns in data
Uses any data - not trained on "right" outputs
Used for clustering and dimensionality reduction
Example: Market segmentation where customer data are grouped into segments without pre-assigned labels, helping a business tailor its strategies to different customer groups.
7. Types of Machine Learning (Continued)
7.3 Reinforcement Learning
Reinforcement learning is a type of machine learning where an agent learns by interacting with an environment. It receives rewards for good actions and penalties for poor actions.
📖 Reinforcement Learning Characteristics
Agent learns to make decisions by taking actions in an environment
Aims to maximize cumulative reward
Learns the best actions through trial and error
Receives feedback in terms of rewards or penalties
Over time, learns an optimal strategy called a policy
Application
Description
Robotics
Robots learn to navigate and perform tasks
Self-driving cars
Learn to drive safely in various conditions
Game-playing AI
Like AlphaGo - learns optimal game strategies
Industrial automation
Optimizes manufacturing processes
Example: A robotic vacuum cleaner learns to navigate a room by trying different paths and getting positive feedback when it picks up dirt or negative feedback when it bumps into walls.
💡 Exam Tip - Key Differences
Supervised: Has labelled data with known correct answers
Unsupervised: No labels - finds patterns on its own
Reinforcement: No labels - learns from rewards/penalties through interaction
8. Artificial Neural Networks (ANNs)
Artificial Neural Networks (ANNs) are algorithms inspired by the structure of the human brain. A neural network is made up of layers of nodes (neurons) connected by weighted links.
📖 How ANNs Work
Each neuron receives input, processes it, and passes the result to the next layer
Weights are assigned to connections between nodes - they determine the importance of inputs
Data is fed into the input layer and processed through hidden layers
The network adjusts weights based on errors in output (using backpropagation)
Learning occurs through repetition - network adjusts weights to improve accuracy
⚠️ Why Use ANNs?
Automatically learn from experience, even with complex or unstructured data
Improve accuracy with more data and training
Can solve problems too complex for rule-based programming
Make decisions and infer rules without explicit programming
9. Deep Learning
Deep learning is a specialized subset of machine learning that uses deep (multi-layered) neural networks. The more layers a network has, the more complex patterns it can learn.
📖 Key Characteristics of Deep Learning
Inspired by human brain - simulates interconnectedness of neurons
Uses multiple hidden layers to extract higher-level features
Excellent at identifying patterns in complex data (images, text, audio, video)
Can perform tasks once considered exclusive to human cognition
9.1 Why Multiple Hidden Layers?
📝 Reasons for Multiple Hidden Layers
Facilitating Deep Learning: Multiple layers build a deep hierarchy of concepts, enabling complex pattern learning
Solving Complex Problems: Tasks with higher complexity need multiple layers to capture nuances and abstract features
Autonomous Learning: Neural networks can learn from data and make decisions without explicit programming
Enhancing Accuracy: Additional layers provide more nuanced understanding, improving predictions
Example - Image Recognition: Early layers might detect edges, while deeper layers identify more complex features like shapes or objects. In facial recognition, early layers detect features like eyes and noses, deeper layers recognize complete faces.
Application
How Deep Learning Helps
Facial Recognition
Learns features like eyes, noses, then full faces through many layers
Self-driving Cars
Interprets sensor data and makes driving decisions autonomously
Medical Diagnosis
Identifies subtle patterns in medical images indicative of diseases
Language Translation
Understands context and nuance in language
🌟 Deep Learning vs Machine Learning
While machine learning may require manual feature identification and relies on smaller datasets, deep learning leverages multiple layers to autonomously learn features directly from large amounts of data, often resulting in more accurate and robust models.
10. Back Propagation
Back propagation is a fundamental process in training neural networks. It's an iterative process where the network's performance is constantly evaluated and improved.
📖 How Back Propagation Works
Feedback Mechanism: Errors from predictions are sent backward through the network layers
Informs how much each neuron's output contributed to the overall error
Continuous Improvement: Weights are adjusted to reduce errors with each iteration
Goal-Oriented: Adjustments aim to bring output closer to expected results
10.1 Back Propagation Steps
📝 The Four Stages of Back Propagation
Forward Pass: Input data passes through the network layer by layer. The network produces an output (prediction).
Error Calculation: The output is compared to the actual target value. The difference is called the error.
Backward Pass: The error is propagated backwards through the network. Each layer calculates its contribution to the error.
Weight Adjustment: Weights are updated using an algorithm (e.g., gradient descent) to reduce future errors.
⚠️ Why Use Back Propagation?
Helps the neural network learn from mistakes
Makes the model more accurate over time
Allows multi-layer networks to fine-tune all layers, not just the output
Common in: image recognition, speech recognition, language translation
🧠 Memory Trick
Think of back propagation like learning from mistakes:
Forward: "Let me try this" (make a prediction)
Error: "How wrong was I?" (calculate difference)
Backward: "What caused my mistake?" (identify error sources)
Adjust: "I'll do better next time" (update weights)
11. Regression
Regression is a type of supervised learning used to predict continuous values (rather than categories). The aim is to find the relationship between input features and a numerical output.
📖 What is Regression Analysis?
A statistical method for examining relationships between variables
Used to predict outcomes (output) from input data
Discerns the relationship between input and output
Finds the best-fit line/curve through data points
11.1 Types of Regression
Type
Description
Example
Linear Regression
Predicts output using a straight-line relationship (y = mx + c)
Predicting house prices from size
Multiple Linear Regression
Uses multiple input features to predict one continuous output
Predicting price from size, location, age
Logistic Regression
Predicts binary outcomes (yes/no), despite the name "regression"
Will customer buy? (Yes/No)
Example: Predicting house prices based on square footage - Input: size of house, Output: estimated price. The model learns a line that best fits the data points.
11.2 Why Use Regression?
📝 Applications of Regression
Forecasting: Predicting future trends
Trend Analysis: Understanding data patterns
Risk Prediction: Financial and medical risk assessment
Business Analytics: Sales predictions, customer behavior
Healthcare: Patient outcome predictions
12. Exam-Style Questions
1. Supervised and unsupervised learning are two categories of machine learning. Describe supervised learning and unsupervised learning. [4 marks]
Answer:
Supervised learning (Max 3 marks):
Supervised learning allows data to be collected, or a data output produced, from previous experience
In supervised learning, known input and associated outputs are given OR uses sample data with known outputs (in training) OR uses labelled input data
Able to predict future outcomes based on past data
Unsupervised learning (Max 3 marks):
Unsupervised machine learning helps all kinds of unknown patterns in data to be found
Unsupervised learning only requires input data to be given
Uses any data OR not trained on the right output OR uses unlabelled input data
Additional points for deeper understanding:
Supervised: Used for classification and regression tasks
Unsupervised: Used for clustering and pattern recognition
2. Explain the difference between Dijkstra's algorithm and the A* algorithm. [4 marks]
Answer:
Dijkstra's algorithm considers only the actual cost g(x) from the start node
A* uses f(x) = g(x) + h(x) where h(x) is a heuristic estimate to the goal
Dijkstra's is not goal-aware - explores all nodes equally
A* is goal-aware - uses heuristic to move toward goal more directly
A* is typically faster as it explores fewer nodes
Dijkstra's is best for finding shortest paths to all nodes
A* is best for finding the fastest route to a specific destination
3. Describe the purpose of the heuristic function in the A* algorithm. [4 marks]
Answer:
The heuristic function h(x) estimates the remaining distance/cost to the goal
It helps the algorithm prioritize paths that appear to lead most directly to the destination
The heuristic should never overestimate the true cost to ensure optimality
Common heuristic is straight-line (Euclidean) distance to the goal
The closer h(x) is to the true cost, the fewer nodes A* needs to explore
It makes the algorithm more goal-oriented and efficient
4. Explain what is meant by back propagation in neural networks. [5 marks]
Answer:
Back propagation is a training method used to improve neural network accuracy
It works by adjusting the weights of connections between neurons
Errors from predictions are propagated backward through the network layers
Each layer calculates its contribution to the error
Weights are updated using algorithms like gradient descent
The process repeats until predictions reach acceptable accuracy
It allows the network to learn from its mistakes
5. Describe how Dijkstra's algorithm finds the shortest path. [5 marks]
Answer:
Set the start node's distance to 0 and all other nodes to infinity
Mark all nodes as unvisited
Select the unvisited node with the lowest distance
For each neighbour, calculate new distance through current node
If new distance is smaller than current, update it
Mark current node as visited
Repeat until all nodes visited or goal reached
Backtrack from goal to find the shortest path
12. Exam-Style Questions (Continued)
6. Describe the characteristics of an undirected, weighted graph and give an example of its use in AI. [4 marks]
Answer:
Edges go both ways (no direction)
Each edge has a weight representing cost, distance, time, or risk
If no connection exists, the matrix contains ∞ (infinity)
The adjacency matrix is symmetric
Example: Pathfinding algorithms like A* or Dijkstra finding lowest cost path
Example: Clustering with similarity weights between data points
7. Explain the difference between deep learning and traditional machine learning. [5 marks]
Answer:
Deep learning uses multiple hidden layers in neural networks
Traditional ML may require manual feature identification
Deep learning autonomously learns features from large amounts of data
Deep learning excels at complex patterns in images, text, audio, video
Deep learning typically requires more data and computational power
Traditional ML works well with smaller datasets
Deep learning often results in more accurate and robust models
8. Describe how graphs can be represented in computer systems. [4 marks]
Answer:
Adjacency Matrix: 2D array where matrix[i][j] = 1 if edge exists between nodes i and j
Ideal for dense graphs with fast edge lookup
Uses O(n²) space where n is number of nodes
Adjacency List: Stores list of neighbours for each node
More space-efficient for sparse graphs
Uses O(V+E) space (vertices + edges)
Often used in AI search algorithms
9. Explain what is meant by reinforcement learning and give an example application. [4 marks]
Answer:
Agent learns to make decisions by taking actions in an environment
Aims to maximize cumulative reward
Learns through trial and error with feedback
Receives rewards for good actions and penalties for poor actions
Over time, learns an optimal strategy called a policy
Example: Self-driving cars learning to navigate safely
Example: Game-playing AI like AlphaGo learning optimal strategies
10. Describe the role of hidden layers in artificial neural networks. [5 marks]
Answer:
Hidden layers are layers between input and output layers
They transform data received from input layers through computational processes
Progressively extract higher-level features from raw input
Early layers may detect simple features (edges), deeper layers detect complex features (objects)
Multiple hidden layers enable deep learning
Allow network to build a deep hierarchy of concepts
More layers = ability to learn more complex patterns
Results from hidden layers are used to make decisions at the output layer
13. Glossary
📖 Key Terms
Artificial Intelligence (AI): Capability of a computer to perform tasks that typically require human intelligence, such as reasoning, learning, and problem-solving.
Graph: A set of vertices/nodes connected by edges/arcs, used to model relationships and networks.
Directed Graph: A graph where edges have direction - connections go from one node to another.
Undirected Graph: A graph where edges have no direction - connections go both ways.
Weighted Graph: A graph where edges have weights representing cost, distance, or time.
Adjacency Matrix: 2D array representation of a graph where matrix[i][j] indicates connection between nodes i and j.
Adjacency List: Representation storing a list of neighbours for each node in a graph.
Dijkstra's Algorithm: Algorithm for finding the shortest path from a start node to all other nodes in a weighted graph.
A* Algorithm: Pathfinding algorithm using heuristics to find the shortest path more efficiently than Dijkstra's.
Heuristic: An estimate or educated guess used to guide search algorithms toward a goal.
Machine Learning (ML): Subset of AI where algorithms learn from data without explicit programming.
Supervised Learning: ML where the algorithm is trained on labelled data with known outputs.
Unsupervised Learning: ML where the algorithm finds patterns in unlabelled data.
Reinforcement Learning: ML where an agent learns through trial and error with rewards and penalties.
Artificial Neural Network (ANN): Algorithm inspired by the brain, made of layers of connected nodes.
Deep Learning: ML using neural networks with multiple hidden layers.
Back Propagation: Training method where errors are propagated backward to adjust weights in a neural network.
Regression: Supervised learning method for predicting continuous numerical values.
14. Exam Success Tips (Part 1)
💡 Graph Types - Quick Reference
Undirected + Unweighted: Symmetric matrix, 1s and 0s, no direction or cost
Directed + Unweighted: Non-symmetric matrix, 1s and 0s, direction matters
Undirected + Weighted: Symmetric matrix, weights for costs, ∞ for no connection
Directed + Weighted: Non-symmetric matrix, weights + direction, ∞ for no connection
💡 Dijkstra's Algorithm Steps
Step 1: Set start = 0, all others = ∞
Step 2: Mark all as unvisited
Step 3: Visit node with lowest distance
Step 4: Update neighbours if new path is shorter
Step 5: Mark as visited, repeat until goal reached
Step 6: Backtrack to find shortest path
💡 A* Formula - Must Remember!
f(x) = g(x) + h(x)
g(x) = actual cost from start to current node
h(x) = heuristic estimate to goal (never overestimate!)
f(x) = total estimated cost through node x
A* chooses nodes with lowest f(x) value
🧠 Memory Trick: A* Formula
g = "gone" (distance you've already traveled)
h = "hope" (estimated distance remaining)
f = "future" (total estimated cost)
14. Exam Success Tips (Part 2)
💡 Machine Learning Types - Key Differences
Supervised: Labelled data (has answers) → Classification & Regression
Unsupervised: No labels → Clustering & Pattern finding
Reinforcement: No labels → Trial & error with rewards/penalties
💡 Neural Networks Key Points
Input Layer: Receives data
Hidden Layers: Transform data, extract features
Output Layer: Produces predictions
Weights: Determine importance of connections
Deep Learning: Multiple hidden layers = more complex patterns
❌ Common Mistakes to Avoid
Don't confuse directed (one-way) with undirected (both ways) graphs
Don't forget: adjacency matrix for directed graphs is NOT symmetric
Don't say A* is "faster than Dijkstra" without context - it's more goal-directed
Don't confuse regression (continuous output) with classification (categorical)
Don't forget: heuristic h(x) should never overestimate true cost
Don't mix up back propagation (training method) with forward propagation
💡 Back Propagation Steps
Forward Pass: Data through network → prediction
Error Calculation: Compare prediction to actual
Backward Pass: Propagate error backward
Weight Adjustment: Update weights to reduce error
15. Key Takeaways
📌 Summary Points
AI & Graphs
Graphs: Vertices + edges, used to model relationships and decision problems
Adjacency Matrix: O(n²) space, good for dense graphs
Adjacency List: O(V+E) space, better for sparse graphs
Pathfinding Algorithms
Dijkstra's: Finds shortest path to all nodes, uses g(x) only
A*: Goal-oriented, uses f(x) = g(x) + h(x) with heuristic
Heuristic: Must never overestimate true cost
Machine Learning
Supervised: Labelled data, known outputs, classification/regression
Unsupervised: No labels, finds patterns, clustering
Reinforcement: Trial and error, rewards/penalties, policies
Neural Networks
ANNs: Layers of nodes connected by weighted links
Deep Learning: Multiple hidden layers for complex patterns
Back Propagation: Adjusts weights by propagating errors backward
Regression
Purpose: Predict continuous values from input features
Artificial Intelligence continues to transform our world. From pathfinding algorithms powering GPS navigation to deep learning enabling facial recognition and self-driving cars, these concepts form the foundation of modern AI systems. Understanding these fundamentals is essential for any computer scientist!