-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappendix-b.tex
109 lines (89 loc) · 2.4 KB
/
appendix-b.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
\section*{Приложение Б - Псевдокод алгоритма RKR-GST}
\addcontentsline{toc}{section}{Приложение Б - Псевдокод алгоритма RKR-GST}
Псевдокод для основного тела алгоритма
\newline
\begin{algorithm}[H]
\SetAlgoLined %% Это соединяет линиями логические части
search-length s := initial-search-length;
stop := false;
\Repeat{stop} {
$L_{max}$ := scanpattern(s);
\eIf{$L_{max}$ > 2 $\times$ s}{
s := $L_{max}$;
}{
markstrings(s);
\eIf{s > 2 $\times$ minimum\_match\_length}{
s := s div 2;
}{
\eIf{s > minimum\_match\_length}{
s := $minimum\_match\_length$;
}{
stop := true;
}
}
}
}
\end{algorithm}
\newpage
Псевдокод для функции $scanpattern()$
\newline
\begin{algorithm}[H]
\small
\SetAlgoLined
\For{unmarked tokens $T_t$}{
\eIf{distance to next tile $\le$ s}{
advance $t$ to first unmarked token after next tile;
}{
create the KR hash-value for substring $T_t$ . . . $T_{t + s - 1}$ and add to hashtable;
}
}
\For{unmarked tokens $P_p$}{
\eIf{distance to next tile $\le$ s}{
advance $p$ to first unmarked token after next tile;
}{
create the KR hash-value for substring $P_p$ . . . $P_{p + s - 1}$ and add to hashtable;
check hashtable for hash of KR hash-value;
\For{each hash-table entry with equal hashed KR hash-value}{
k := s;
\While{$P_{p + k} = T_{t + k} \ \& \ unmarked(P_p + k) \ \& \ unmarked(T_t + k)$}{
k := k + 1;
}
\eIf{k > 2 $\times$ s}{
return(k);
}{
record new maximal-match;
}
}
}
}
return(length of longest maximal-match);
\end{algorithm}
\newpage
Псевдокод для функции $markstrings()$
\newline
\begin{algorithm}[H]
\small
\SetAlgoLined
\While{$queue\ non-empty$}{
\eIf{$current\ queue\ is\ empty$}{
drop to next queue;
}{
remove match(p, t, L) from queue;
\eIf{$match\ not\ occluded$}{
\For{$j\leftarrow 0$ \KwTo $s-1$}{
\eIf{$P_{p+j} = T_{t+j}$}{
\For{$i\leftarrow 0$ \KwTo $s-1$}{
mark\_token($P_{p + i}$);
mark\_token($T_{p + i}$);
}
$length\_of\_tokens\_tiled := length\_of\_tokens\_tiled + L$;
}
}
}{
\eIf{$L - L_{occluded} \ge s $}{
replace unmarked portion on list of queues;
}
}
}
}
\end{algorithm}