How can I write the else if block with condition with the usepackage algorithm2e?

I want to write the following with the algorithm2e package:

 }else if(condition){
  // code


%Header part
%\cfoot{center of the footer!}


\usepackage{ amssymb }



function search(v,w,s) \\
   binarsearch(v,w,s,0, |w|) \\

   binarsearch(v,w,s,l, r) \\

   \If{$v$ prefix of $w_s[m]$}{
      return true;
   }\ElseIf(elseif comment){
\label{alg: initializer}

To combine such conditions, write each as a separate component using \uIf and \uElseIf (and \uElse, if needed):

enter image description here




  \uIf{if condition}{
    something if \;
  \uElseIf{elseif condition}{
    something elseif \;
    something else \;
\caption{An algorithm}

  • this answer is helpful. – Primo Raj Jan 16 at 3:43

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.