Sor (Queue)

Animáció

Struktogram

$Queue::add(x: \mathcal{T})$


$Z.length > n$

$Z[(k+n) \space mod \space Z.length] := x$ $\text{error}$
$n := n + 1$

$Queue::rem() : \mathcal{T}$


$n > 0$

$n := n - 1$ $\text{error}$
$i := k$
$k := (k+1) \space mod \space Z.length$
$\text{return} \space Z[i]$

Feladatok