Advertisement
Guest User

Untitled

a guest
Aug 13th, 2014
1,998
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 0.57 KB | None | 0 0
  1. [latex]
  2. [+preamble]
  3.     \usepackage{amsmath}
  4.     \usepackage{algorithm}
  5.     \usepackage{algpseudocode}
  6. [/preamble]
  7. \begin{algorithm}
  8. \caption{String Palindromity}
  9. \begin{algorithmic}[1]
  10. \Function{IsPalindrome}{string text}
  11.     \State $\textit{min} \gets 0$
  12.     \State $\textit{max} \gets \text{length of }\textit{text}$
  13.     \While{true}
  14.         \If {$min > max$} \Return true
  15.         \EndIf
  16.         \If {$text[min] <> text[max]$} \Return false
  17.         \EndIf
  18.     \State $\textit{min} \gets min + 1$
  19.     \State $\textit{max} \gets max - 1$
  20. \EndWhile
  21. \EndFunction
  22. \end{algorithmic}
  23. \end{algorithm}
  24. [/latex]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement