Definitions

# Weight (strings)

The $a$-weight of a string, for $a$ a letter, is the number of times that letter occurs in the string. More precisely, let $A$ be a finite set (called the alphabet), $ain A$ a letter of $A$, and $cin A^*$ a string (where $A^*$ is the free monoid generated by the elements of $A$, equivalently the set of strings, including the empty string, whose letters are from $A$). Then the $a$-weight of $c$, denoted by $mathrm\left\{wt\right\}_a\left(c\right)$, is the number of times the generator $a$ occurs in the unique expression for $c$ as a product (concatenation) of letters in $A$.

If $A$ is an abelian group, the Hamming weight $mathrm\left\{wt\right\}\left(c\right)$ of $c$, often simply referred to as "weight", is the number of nonzero letters in $c$.

## Examples

• Let $A=\left\{x,y,z\right\}$. In the string $c=yxxzyyzxyzzyx$, $y$ occurs 5

times, so the $y$-weight of $c$ is $mathrm\left\{wt\right\}_y\left(c\right)=5$.

• Let $A=mathbf\left\{Z\right\}_3=\left\{0,1,2\right\}$ (an abelian group) and $c=002001200$. Then $mathrm\left\{wt\right\}_0\left(c\right)=6$, $mathrm\left\{wt\right\}_1\left(c\right)=1$, $mathrm\left\{wt\right\}_2\left(c\right)=2$ and $mathrm\left\{wt\right\}\left(c\right)=mathrm\left\{wt\right\}_1\left(c\right)+mathrm\left\{wt\right\}_2\left(c\right)=3$.

Search another word or see stringson Dictionary | Thesaurus |Spanish