How to write this algorithm pseudocode in latex:

Algorithm 1  Channel Assignment using Random Ordering (RO)
    K←Set of channels
    root← Root Selection(V)
    C(root)← Channel Selection(root,K)  
    while  (V!=Empty)
                  v← Removehead(V)
                  C(v)←Channel Selection (v,K) 
    end while
  • 1
    Can you show us what you've tried?
    – Werner
    Dec 20, 2016 at 7:05
  • Welcome! Add a MWE, please.
    – Sebastiano
    Dec 20, 2016 at 7:32
  • Googling for "latex algorithm" yields Wikibooks: LaTeX/Algorithms, among other tutorials. This seems to be a good starting point.
    – gernot
    Dec 20, 2016 at 8:58

1 Answer 1


Here is an implementation of an algorithm in pseudocode using algorithm2e:

  $K \gets \text{Set of channels}$\;
  $C(v) \gets 0,\forall v \in V$\;
  $\text{root} \gets \text{Root Selection}(V)$\;
  $C(\text{root}) \gets \text{Channel Selection}(\text{root},K)$\;
  \While{$V \neq \emptyset$}
    $v \gets \text{Removehead}(V)$\;
    $C(v) \gets \text{Channel Selection}(v,K)$\;
    $V \gets V-1$\;
  \caption{Channel Assignment using Random Ordering (RO)}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.