You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers vectors as a data structure and mathematical concept, as specified in the OCR A-Level Computer Science (H446) specification, section 1.4. Vectors are used in graphics, physics simulations, machine learning, and many other areas of computing.
A vector is a mathematical object that has both magnitude (size) and direction. In computing, vectors are represented as ordered lists of numbers.
| Concept | Description | Example |
|---|---|---|
| Scalar | A single number (magnitude only) | Temperature: 20, Speed: 5 |
| Vector | An ordered list of numbers (magnitude and direction) | Position: (3, 4), Velocity: (2, -1, 5) |
Vectors can be represented as lists or arrays of numbers. A vector with n components is called an n-dimensional vector.
2D vector: v = (3, 4) -- 2 components
3D vector: w = (1, -2, 5) -- 3 components
4D vector: u = (1, 0, 3, 7) -- 4 components
A vector can also be thought of as a function that maps indices to values:
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.