# Algorithm mashing into definitions and overfull / underfull warnings

In a long latex doc I have I get my algorithm inserted into my definition for some reason. I apologize for not having a small working example I could not get one to work. Have a bunch of overfull and underfull errors can that actually cause a problem? And what would be the easiest way to fix such? See here:

\begin{algorithm}
\caption{Primal-dual}
\begin{algorithmic}
\STATE $c \leftarrow w.$
\STATE $S = \{u \in V : w(u) = 0 \}$.
\WHILE{$S$ is not a hitting set for $C$}
\STATE  $\mathcal{M}$  a collection of cycles returned by a violation oracle Violation$(G, C, S)$.
\STATE $c_{ \mathcal{M} (u) } \leftarrow |{M _ M : u _ M}|, \forall u \in V$.
\STATE $\alpha \leftarrow min_ {u \in V \backslash S} | w(u)| / c_{\mathcal{M} (u) }$
$\bar{ w(u) } \leftarrow w(u) - \alpha cM (u),$ for all u in V.
$S \leftarrow \{u _ V : w(u) = 0 \}.$
\ENDWHILE
%end
return a minimal hitting set $H \subset S$ of $\mathcal{C}$.
\end{algorithmic}
\end{algorithm}

\begin{definition}
For $p \geq 3$ a $p$-pocket for a planar graph G(V; E) and a cycle collection $\mathcal{C}$, is a set U $\subset$ V such that: \\
1. The set U contains at most $p$ nodes  with neighbors outside U. (we call these contact nodes) \\
2. The induced subgraph $G_S [U]$ has at least p faces in $\mathcal{C}$.
\end{definition}

• Please, even if you don't have a very MWE, please insert at list one that is workable so one can use to test a solution. – gvgramazio May 1 '18 at 10:51
• I think that it happens because LaTeX prefers to non break a page inside the algorithm environment. In this case you can manually insert a \newpage before your definition or you can redefine the algorithm environment. – gvgramazio May 1 '18 at 10:53
• You can also try to pass the optional argument H to the algorithm environment. – gvgramazio May 1 '18 at 11:20
• Thank you that did the trick btw what does the [H} do? – Hao S May 1 '18 at 18:23
• I provided an answer that should clear your doubts, if you have other doubts please ask. – gvgramazio May 2 '18 at 9:14