# Parameters of a linear code

Consider the code $C=\{c=(c_1...c_n): c \in \Bbb F_q^n, c_1=c_n\} \subset \Bbb F_q^n$.

I was able to prove that the code is a linear code because it is closed under addition and scalar multiplication. Also, it is clear that the length is n.

However I am having a hard time with minimum distance, dimension, and size.

For minimum distance: I know that for a linear code the minimum distance is equal to the minimum weight, or number of places with nonzero entries, of all nonzero codewords in C. However, I think the minimum weight can range between 1 to n entries, so does this mean that the minimum distance is 1?

For dimension and size: I know that the dimension is the order of the basis for C. I think that the basis is $B=\{10...01, 010...0, 001...0, ... , 0...010\}$, and so the dimension would be $n-1$, but I am unsure on this. If the dimension is $n-1$, then the size would be $q^{n-1}$.

Any help is appreciated, thank you in advanced. Please also let me know if this post does not belong to this stack exchange.

## migrated from crypto.stackexchange.comMar 17 '18 at 9:47

This question came from our site for software developers, mathematicians and others interested in cryptography.

You're right, minimum distance is the minimal nonzero weight, thus 1.

A basis is what you gave. There are many bases. And youre right on size and dimension as well.

Edit: As pointed out in the other answer the distance is 2 if $n=2.$

There is one exception in which the minimum distance is unequal to 1, and this is in the case that $n=2$. Since this is the code $C=\{ 00,11 \}$.

For all the other cases:

For $n=1$: the code $C=\{0,1\}$ and thus having minimum distance 1.

For $n > 2$: the codeword $c$ is in $C$ such that $c=(c_1,...,c_n)$ in which $c_1=c_n=0$ and there exists one $c_i=1$ such that $1<i<n$.