Algorithm Table
The algtable environment produces a special purpose table similar to the Reference Table that can be used to provide a table of algorithm time-complexities. It is derived from the tabular environment and accepts all of the same arguments. The Algorithm Table differs from the Reference Table table in that the left column is wider and left aligned, while the right column is narrow and the data center aligned. In the description below, only the most commonly used arguments are included.
tables module
\begin{algtable}[
ncols=2
width=50%
headalign='c|c|c|c|c'
colalign='l|c|c|c|c'
colclass='|math'
colwidth='70%|30%'
style=names]
\headers{Operation}{Worst-Case}
\row{add(x)}{O(n)}
\row{find(x)}{O(n''2'')}
\end{algtable}
A specialized form of the DocumentTable that can be used to produce a table listing the time-complexities for various algorithms. It has a number of preset arguments:
- the default is for 2 columns
- head cells are center aligned for up to five columns
- the left column is left aligned, and right column is centered aligned. Alignments are provided for up to five columns.
- default column widths (70% left, 30% right)
Plugin: AlgorithmTable
An example algorithm table is illustrated below
Example
source
- \begin{algtable}
- \headers{ADT Operation}{Worst-Case}
- \row{length}{O(1)}
- \row{search}{O(n)}
- \row{add}{O(n)}
- \row{remove}{O(n)}
- \row{replace}{O(n'^2^')}
- \end{algtable}
| ADT Operation | Worst-Case |
|---|---|
| length | O(1) |
| search | O(n) |
| add | O(n) |
| remove | O(n) |
| replace | O(n'^2^') |
results