1
$\begingroup$

First of all I'm a Physics Student and I've been arguing with my brother concerning the usage and the fundamental meaning of a vector on Computer Science (CS).

I) Vectors

A vector have a axiomatic meaning, i.e., given a set $\mathcal{A}$ of objects, their objects can be called vectors if and only if they satisfy the vector space axioms $[1]$. Of course that, 3D vectors (little arrows), function, matrices and so on are different objects, but under a well defined vector addition $\boxplus$, and scalar multiplication $\boxdot$ they are the same: Vectors!

Furthermore, I think that is impossible to talk about more complicated objects like Tensors without a vector space structure underlying the mathematical usage of CS objects.

II) My doubt

So, I would like to know: arrays, lists, strings are the same object as vectors? In other words, they satisfy the vector space axioms?

$$* * *$$

$[1]$ https://en.wikipedia.org/wiki/Vector_space#Definition

$\endgroup$
1
$\begingroup$

The objects you mention are not the same. In particular, lists and (mutable) strings are dynamic data structures whereas arrays are not; their size is fixed. Now, whether some set of instances of data structures forms a vector space depends on the underlying types, some do, others do not. Considering e.g. boolean arrays of fixed size $n$ together with the usual addition/scalar multiplication of $\mathbb F_2^n$ yields a vector space, integer arrays of fixed size $n$ do not yield one with the usual operations.

$\endgroup$
0
$\begingroup$

Array: maps consecutive integers to array elements. Often maps integers fro 0 to n-1. Arrays may have fixed or variable size, depending on the implementation.

List: A list is either empty, or it has a first element, and each element except the last has a link to the next element. Allows inserting and removing elements. Depending on the implementation, iterating from the first to the last element, and possibly also iterating from the last to the first element can be done quickly. Often an array is used to implement a list.

Vectors are basically the same as arrays under a different name.

Strings... are complicated. They often use an array of bytes for implementation, but have tons of specialised operations because they are meant for human-readable text. Characters can be represented as ASCII, but more likely UTF-8 etc. String libraries may fully support Unicode, and then your knowledge about arrays will be totally misleading. I recommend looking at strings as a basic type like integer, floating point number, etc.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.