📄 Paper 1 · 4.2 Data Structures
⭐ Pro
4.2.8 Vectors
AQA 7517 · A-Level Computer Science · ~16 min read

What is a Vector?

In computer science (AQA 7517), a vector is a mathematical object representing a quantity with both magnitude and direction. Vectors are used in machine learning, computer graphics, physics simulations, and data science.

A vector can be represented as a 1D array of real numbers:

v = (3, 4)        // 2D vector
u = (1, 2, 3)     // 3D vector
w = (0.5, 1.2, -0.8, 2.1)  // 4D vector

Vector Representation

In AQA 7517, vectors are represented as a list of numbers (components). A vector of dimension n has n components.

// AQA representation using a 1D array
v ← [3, 4]   // vector with 2 components

Vector Operations

1. Addition

Add corresponding components:

u = (1, 2, 3)
v = (4, 5, 6)
u + v = (1+4, 2+5, 3+6) = (5, 7, 9)

2. Scalar Multiplication

Multiply each component by a scalar (number):

v = (2, 3, 4)
3 × v = (3×2, 3×3, 3×4) = (6, 9, 12)

3. Dot Product

Multiply corresponding components and sum the results. Result is a scalar (number):

u = (1, 2, 3)
v = (4, 5, 6)
u · v = (1×4) + (2×5) + (3×6)
      = 4 + 10 + 18
      = 32

The dot product is used in: cosine similarity (angle between vectors), neural networks, recommendation systems.

4. Vector Convolution

Convolution slides one vector across another, computing element-wise products and summing. Used in signal processing and convolutional neural networks (CNNs).

// Convolution of [1,2,3] with kernel [0,1,0]:
Position 0: 1×0 + 2×1 + 3×0 = 2
// This is a simplified 1D convolution

Magnitude (Length) of a Vector

The magnitude of vector v = (v₁, v₂, v₃) is:

|v| = √(v₁² + v₂² + v₃²)

// Example: v = (3, 4)
|v| = √(3² + 4²) = √(9 + 16) = √25 = 5

Applications of Vectors in Computing

ApplicationHow vectors are used
Machine learningData points represented as feature vectors; dot products compute similarity
Computer graphicsPositions, colours, and normals represented as vectors
Natural language processingWord embeddings — words represented as high-dimensional vectors
Physics simulationVelocity, acceleration, force represented as vectors
Recommendation systemsUser and item preference vectors; cosine similarity measures overlap
Exam tip: Know vector addition, scalar multiplication, and dot product. Be able to calculate these for given vectors. Know that the dot product results in a scalar. Know the magnitude formula √(sum of squares). Link vectors to real-world computing applications such as machine learning and graphics.
Click through the slides at your own pace. Use arrow keys or click to advance.
Click slide or press arrow keys to navigate

Worksheet — 4.2.8 Vectors

8 questions · instantly marked · AQA 7517 standard

Q1What is a vector in computing? What two properties does a vector have?[2]
✅ Mark scheme
Mark scheme
A mathematical object/list of numbers representing magnitude and direction [1]; a vector has magnitude (size/length) and direction [1].
Q2Given u = (2, 5, 1) and v = (3, 1, 4), calculate u + v.[2]
✅ Mark scheme
Mark scheme
Add corresponding components [1]: u + v = (2+3, 5+1, 1+4) = (5, 6, 5) [1].
Q3Given v = (1, 3, 2), calculate 4 × v.[2]
✅ Mark scheme
Mark scheme
Multiply each component by 4 [1]: 4 × (1,3,2) = (4, 12, 8) [1].
Q4Calculate the dot product of u = (2, 3, 1) and v = (4, 1, 5). What type of value does the dot product produce?[3]
✅ Mark scheme
Mark scheme
u · v = (2×4) + (3×1) + (1×5) = 8 + 3 + 5 = 16 [2]; the dot product produces a scalar (a single number) [1].
Q5Calculate the magnitude of v = (3, 4).[2]
✅ Mark scheme
Mark scheme
|v| = √(3² + 4²) = √(9 + 16) = √25 = 5 [2] — one mark for correct formula, one mark for correct answer.
Q6Explain how the dot product can be used to measure similarity between two vectors.[2]
✅ Mark scheme
Mark scheme
The dot product measures the angle between two vectors / cosine similarity [1]; a higher dot product (for unit vectors) indicates the vectors point in a similar direction / are more similar [1].
Q7Give two applications of vectors in computing.[2]
✅ Mark scheme
Mark scheme
Any two: machine learning — data points as feature vectors [1]; computer graphics — positions/colours as vectors [1]; NLP — word embeddings [1]; physics simulation — velocity/force as vectors [1]; recommendation systems — user preference vectors [1].
Q8A vector v = (6, 8). Another vector w = (0, 5). Calculate v · w and |v|.[3]
✅ Mark scheme
Mark scheme
v · w = (6×0) + (8×5) = 0 + 40 = 40 [2]; |v| = √(6² + 8²) = √(36 + 64) = √100 = 10 [1].
Topic Quiz
Question 1 of 15
You scored
out of 15
Card 1 of 8
Click to reveal definition
🎉
All cards reviewed!
TermDefinition
🎯

Mini Test — Vectors

10 questions · 10 minutes

← 4.2.7 Dictionaries
18 of 70 · AQA 7517
4.3.1 Graph Traversal →