etnms/algorithm.tex
author Chengsong
Fri, 10 Jan 2020 16:16:59 +0000
changeset 96 abad02dd7719
parent 94 2e2dca212fff
permissions -rw-r--r--
removed sth
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
94
Chengsong
parents:
diff changeset
     1
\documentclass{article}
Chengsong
parents:
diff changeset
     2
\usepackage[ruled,vlined]{algorithm2e}
Chengsong
parents:
diff changeset
     3
 
Chengsong
parents:
diff changeset
     4
\begin{document}
Chengsong
parents:
diff changeset
     5
\begin{algorithm}[H]
Chengsong
parents:
diff changeset
     6
\SetAlgoLined
Chengsong
parents:
diff changeset
     7
\KwResult{rexp }
Chengsong
parents:
diff changeset
     8
 Compute list $l_1: [r_1\backslash c_1 \cdots c_n, r_1\backslash c_1 \cdots c_{n-1}, ..., r_1 \backslash c_1, r_1]$\;
Chengsong
parents:
diff changeset
     9
 Compute list $l_2: [r_2, r_2\backslash c_n, r_2\backslash c_{n-1} c_{n}, ..., r_2 \backslash c_1\cdots c_n]$\;
Chengsong
parents:
diff changeset
    10
 Compute list $l_3$: 
Chengsong
parents:
diff changeset
    11
 $l_3 \gets []$ \;
Chengsong
parents:
diff changeset
    12
 \For{$i\gets1$ \KwTo $n$}{
Chengsong
parents:
diff changeset
    13
    $\mathit{if} \; \mathit{nullable}(r_1 \backslash c_1 \cdots c_{n-i+1}) \; \mathit{then} \; \mathit{add} \; i \; \mathit{to} \; l_3$
Chengsong
parents:
diff changeset
    14
    }
Chengsong
parents:
diff changeset
    15
    $result \gets r_1 \backslash c_1 \cdots c_n \cdot r_2$\\
Chengsong
parents:
diff changeset
    16
 \For{$i\gets0$ \KwTo $l_3.length -1$}{
Chengsong
parents:
diff changeset
    17
 $result \gets \mathit{ALT}(result, l2[l3[i]])$
Chengsong
parents:
diff changeset
    18
 }
Chengsong
parents:
diff changeset
    19
 \Return result
Chengsong
parents:
diff changeset
    20
 \caption{ders2forSEQ($r_1$,$r_2$,$s$)}
Chengsong
parents:
diff changeset
    21
\end{algorithm}
Chengsong
parents:
diff changeset
    22
\end{document}