%% Algorithm Environment Template
%% Auto-generated by ggen from RDF ontology
%% Uses algorithm2e package

\begin{algorithm}[{% raw %}{{ placement | default(value="htbp") }}{% endraw %}]
\caption{% raw %}{{{ caption }}}{% endraw %}
\label{% raw %}{alg:{{ algorithm_id }}}{% endraw %}

{% raw %}{% if input_params %}
\KwIn{%
{% for param in input_params %}
${{ param.symbol }}$ -- {{ param.description }}{% if not loop.last %}, {% endif %}
{% endfor %}
}
{% endif %}{% endraw %}

{% raw %}{% if output_params %}
\KwOut{%
{% for param in output_params %}
${{ param.symbol }}$ -- {{ param.description }}{% if not loop.last %}, {% endif %}
{% endfor %}
}
{% endif %}{% endraw %}

{% raw %}{% if initialization %}
\BlankLine
\tcp{Initialization}
{% for init in initialization %}
{{ init }}\;
{% endfor %}
{% endif %}{% endraw %}

\BlankLine
{% raw %}{% for step in steps %}
{% if step.is_comment %}
\tcp{{{ step.text }}}
{% elif step.is_if %}
\If{${{ step.condition }}$}{
  {% for substep in step.then_block %}
  {{ substep }}\;
  {% endfor %}
}
{% if step.else_block %}
\Else{
  {% for substep in step.else_block %}
  {{ substep }}\;
  {% endfor %}
}
{% endif %}
{% elif step.is_for %}
\For{${{ step.iterator }}$ in ${{ step.range }}$}{
  {% for substep in step.body %}
  {{ substep }}\;
  {% endfor %}
}
{% elif step.is_while %}
\While{${{ step.condition }}$}{
  {% for substep in step.body %}
  {{ substep }}\;
  {% endfor %}
}
{% else %}
{{ step.text }}\;
{% endif %}
{% endfor %}{% endraw %}

\BlankLine
\Return{% raw %} ${{ return_value }}$\;{% endraw %}

\end{algorithm}

{% raw %}{% if complexity %}
\noindent \textbf{Complexity:} {{ complexity.time_complexity }} time, {{ complexity.space_complexity }} space.
{% endif %}{% endraw %}

{% raw %}{% if notes %}
\noindent \textbf{Note:} {{ notes }}
{% endif %}{% endraw %}
