[Tex/LaTex] Writting Recursive algorithm (LCS) using algorithm2e package similar to the one shown in attached image


enter image description here

I want to write this algorithm (recursive) in latex but I don't know how to do it. I have attached image of the algorithm. Please help me with the code. I am using algorithm2e package. Thanks!!

Best Answer

Nothing very special here. You can do something like this (notice the use of \SetKwFunction to declare a function):



\let\oldnl\nl% Store \nl in \oldnl
  \renewcommand{\nl}{\let\nl\oldnl}}% Remove line number for one line


  \If{$i=0$ or $j=0$}{\KwRet{}}
    print $x_i$


enter image description here

Related Question