1

I have this algorithm:

\begin{algorithm}
  \begin{algorithmic}[1]
    \caption{Build-PGM-Index}
    \State{levels} = array dinamico vuoto;
    \State{i} = 0;
    \State{keys} = A;
    \Repeat
      \State{$M$} = Build-PLA-model($keys, \epsilon$);
      \State{levels[i]} = $M$; \State{i} = $i + 1$;
      \State{m} = $Size(M)$;
      \State{keys} = $[M[0].key, \dots, M[m-1].key]$
    \Until{m = 1}\\
    \Return{levels rovesciato}
  \end{algorithmic}
\end{algorithm}

How can I write the \State{i} = 0; and \State{keys} = A; on the same line?

1 Answer 1

2

\State does not receive an argument; just use

\State i=0; keys = A

However, your typesetting is inconsistent. Use math when needed.

\documentclass{article}
\usepackage{amsmath}
\usepackage{algorithm,algpseudocode}

\begin{document}

\begin{algorithm}
  \begin{algorithmic}[1]
    \caption{Build-PGM-Index}
    \State $\mathit{levels} = \text{array dinamico vuoto}$;
    \State $i = 0$; $\mathit{keys} = A$;
    \Repeat
      \State $M = \textup{Build-PLA-model}(\mathit{keys}, \epsilon)$;
      \State $\mathit{levels}[i] = M$; $i = i + 1$;
      \State $m = \textup{Size}(M)$;
      \State $\mathit{keys} = [M[0].\mathit{key}, \dots, M[m-1].\mathit{key}]$
    \Until{$m = 1$}\\
    \Return $\mathit{levels}$ rovesciato
  \end{algorithmic}
\end{algorithm}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .