  Let $[q\rangle$ denote the integer set $\{0,1,\ldots,...,q-1\}$ and let
$\mathbb{B}=\{0,1\}$. The problem of implementing functions
$[q\rangle\rightarrow\mathbb{B}$ on content-addressable memories (CAMs) is
considered. CAMs can be classified by the input alphabet and the state alphabet
of their cells; for example, in binary CAMs, those alphabets are both
$\mathbb{B}$, while in a ternary CAM (TCAM), both alphabets are endowed with a
"don't care" symbol.
  This work is motivated by recent proposals for using CAMs for fast inference
on decision trees. In such learning models, the tree nodes carry out integer
comparisons, such as testing equality ($x=t$?) or inequality ($x\le t$?), where
$x \in [q\rangle$ is an input to the node and $t \in [q\rangle$ is a node
parameter. A CAM implementation of such comparisons includes mapping (i.e.,
encoding) $t$ into internal states of some number $n$ of cells and mapping $x$
into inputs to these cells, with the goal of minimizing $n$.
  Such mappings are presented for various comparison families, as well as for
the set of all functions $[q\rangle\rightarrow\mathbb{B}$, under several
scenarios of input and state alphabets of the CAM cells. All those mappings are
shown to be optimal in that they attain the smallest possible $n$ for any given
$q$.
