-
Notifications
You must be signed in to change notification settings - Fork 0
/
source_traversal.src
461 lines (449 loc) · 32.4 KB
/
source_traversal.src
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
\input{preamble}
\begin{document}
\section{Bäume}
\subsection{Begrifflichkeiten}
\SidebarCite{gh:tikzpingus}
\SidebarCite{gh:episode-heaps}
\savebox\pinguA{\tikz{\pingu[glasses round, right eye wink, right wing grab,bow tie=paletteA]}}%
\savebox\pinguB{\tikz{\pingu[glasses, left eye wink, right wing grab,tie=paletteB]}}%
\begin{frame}{Der binäre Baum}
\onslide<2->{\centering\tree{%
[25,name=root[42,name=inner1[13,name=inner2[9,name=leaf1][-4,name=leaf2]][8,name=leaf3]][-4,name=inner3[-9,name=leaf4]]]%
\only<12-|handout:2>{\scope[opacity=.5]}
\onslide<3->{\fill[shadeA] (root.north)++(0,2mm) circle [radius=2.15pt] node[left=1.65mm,paletteA,font=\sbfamily] (dr) {Wurzel};
\node[below=-4pt,gray,font=\scriptsize\itshape] at (dr.south) {root};}
\pgfinterruptboundingbox
\onslide<4->{\fill[shadeB] (inner1.north)++(0,2mm) circle [radius=2.15pt] node[left=1.65mm,paletteB,font=\sbfamily] (di) {Innerer Knoten};
\node[below=-4pt,gray,font=\scriptsize\itshape] at (di.south) {inner node};
\foreach\i in {2,3} {\fill[shadeB] (inner\i.north)++(0,2mm) circle [radius=2.15pt];}}
\onslide<5->{\fill[shadeD] (leaf1.west)++(-2mm,0) circle [radius=2.15pt] node[left=1.65mm,paletteD,font=\sbfamily] (dl) {Blatt};
\node[below=-4pt,gray,font=\scriptsize\itshape] at (dl.south) {leaf};
\foreach\i in {2,3,4} {\fill[shadeD] (leaf\i.west)++(-2mm,0) circle [radius=2.15pt];}}
\endpgfinterruptboundingbox
\onslide<7->{
\node[right=1.25cm,gray] (niveau) at (dr-|inner3) {\textbf{Ebene}};
}
\pgfonlayer{background}
\only<12-|handout:2>{\scope[opacity=.5]}
\foreach[count=\i] \x in {root,inner1,leaf3,leaf1} {
\onslide<\the\numexpr\i+7\relax->{
\node[gray,font=\sbfamily] (dn\i) at(\x-|niveau) {\the\numexpr\i-1\relax};
\draw[lgray!90!white,densely dashed, very thick] (dn\i.west) -- (dl.west|-dn\i.west);
}
}
\only<12-|handout:2>{\endscope}
\onslide<13-|handout:2>{%
\scope[paletteC]
\fill (root) circle[radius=1.4em];
\fill (inner3) circle[radius=1.4em];
\fill (leaf4) circle[radius=1.4em];
\draw[line width=3pt+.3em] (root) -- (inner3) -- (leaf4);
\node[left=3mm,font=\sbfamily] (db) at(inner3.west) {Zweig};
\node[below=-4pt,gray,font=\scriptsize\itshape] at (db.south) {branch};
\endscope
}
\endpgfonlayer
\only<12-|handout:2>{\endscope}
}}
\begin{tikzpicture}[overlay,remember picture]
\onslide<6-11|handout:1>{%
\node[below left=.25cm,yshift=.8cm,scale=.6] (pingu) at (current page.north east) {\rotatebox[origin=c]{180}{\usebox\pinguA}};
\node[left,scale=.6,text width=6.75cm,align=center,yshift=-.33cm] at (pingu.west) {\textcolor{gray}{Zur Wiederholung:}\par Blätter haben keine Kindknoten.};
}
\onslide<12-|handout:2>{%
\node[below left=.25cm,yshift=.8cm,scale=.6] (pingu) at (current page.north east) {\rotatebox[origin=c]{180}{\usebox\pinguB}};
\node[left,scale=.6,text width=6.75cm,align=center,yshift=-.33cm] at (pingu.west) {Die gilt auch für Bäume mit mehr als zwei Kindern.};
}
\end{tikzpicture}%
\end{frame}
\SidebarReset
\savebox\pinguA{\tikz{\pingu[headband,glow=paletteC,eyes angry,right wing grab,left wing wave]}}%
\savebox\pinguB{\tikz{\pingu[wings shock,eyes=wink,sunglasses,heart=gray!20!white]}}%
\savebox\pinguC{\tikz{\pingu[right wing grab,left wing wave,hand cast left=\faExclamation,hand cast left color=paletteA,eye patch right,monocle left]}}%
\savebox\pinguD{\tree{[9,w[15,w[8,w]][2,w[7,w][3,m,name=2b][4,w]][3,m,name=3[9,name=9][2,name=2]]]\pgfinterruptboundingbox\draw[shadeA,ultra thick,rounded corners] (9.south west)++(-.5cm,-.5cm) rectangle ([xshift=.5cm,yshift=.5cm]9.north east);\draw[shadeA,ultra thick,rounded corners] (2.south west)++(-.5cm,-.5cm) rectangle ([xshift=.5cm,yshift=.5cm]2.north east);\node[below=12pt,gray,align=center,font=\scriptsize\itshape] at (9.south) {{\upshape\sbfamily Teilbaum 1}};\node[below=12pt,gray,align=center,font=\scriptsize\itshape] at (2.south) {{\upshape\sbfamily Teilbaum 2}};\endpgfinterruptboundingbox}}
\begin{frame}[fragile]{Der rekursive Baum}
\centering
\def\treewidth{.94\linewidth}%
% ugly, but allows me to control handout better
\only<2|handout:0>{\tree{[9[15[8]][2[7][3][4]][3[9][2]]]}}%
\only<3-4|handout:1>{\tree{[9,m,name=root[15,name=15[8,w,name=8]][2,name=2[7,w,name=7][3,w,name=3b][4,w,name=4]][3,name=3[9,w,name=9][2,w,name=2b]]]\pgfinterruptboundingbox\only<4|handout:1>{\draw[shadeA,ultra thick,rounded corners] (7.south west)++(-.5cm,-.5cm) rectangle ([xshift=.5cm,yshift=.5cm]2.north east-|4.north east);\draw[shadeA,ultra thick,rounded corners] (8.south west)++(-.5cm,-.5cm) rectangle ([xshift=.5cm,yshift=.5cm]15.north east);\draw[shadeA,ultra thick,rounded corners] (9.south west)++(-.5cm,-.5cm) rectangle ([xshift=.5cm,yshift=.5cm]3.north east-|2b.north east);\node[above right=1.6mm,font=\sbfamily,paletteA] (dk) at(root.north east) {Knoten};\node[below right,yshift=4pt,gray,font=\scriptsize\itshape] at (dk.south west) {Mit drei Teilbäumen};\node[below=12pt,gray,align=center,font=\scriptsize\itshape] at (8.south) {{\upshape\sbfamily Teilbaum 1}\\(mit Wurzel 15)};\node[below=12pt,gray,align=center,font=\scriptsize\itshape] at (3b.south) {{\upshape\sbfamily Teilbaum 2}\\(mit Wurzel 2)};\path (9.south) -- (2b.south) node[below=12pt,midway,gray,align=center,font=\scriptsize\itshape] {{\upshape\sbfamily Teilbaum 3}\\(mit Wurzel 3)};}\endpgfinterruptboundingbox}}%
\only<5|handout:0>{\tree{[9,w[15,m[8]][2,w[7,w][3,w][4,w]][3,w[9,w][2,w]]]}}%
\only<6|handout:0>{\tree{[9,w[15,w[8,w]][2,m[7][3][4]][3,w[9,w][2,w]]]}}%
\only<7|handout:2>{\tree{[9,w[15,w[8,w]][2,w[7,w][3,w][4,w]][3,m,name=3[9,name=9][2,name=2]]]\pgfinterruptboundingbox\only<7|handout:2>{\draw[shadeA,ultra thick,rounded corners] (9.south west)++(-.5cm,-.5cm) rectangle ([xshift=.5cm,yshift=.5cm]9.north east);\draw[shadeA,ultra thick,rounded corners] (2.south west)++(-.5cm,-.5cm) rectangle ([xshift=.5cm,yshift=.5cm]2.north east);\node[above right=1.6mm,font=\sbfamily,paletteA] (dk) at(3.north east) {Knoten};\node[below right,yshift=4pt,gray,font=\scriptsize\itshape,align=left] at (dk.south west) {Mit zwei\\Teilbäumen};\node[below=12pt,gray,align=center,font=\scriptsize\itshape] at (9.south) {{\upshape\sbfamily Teilbaum 1}\\(mit Wurzel 9)};\node[below=12pt,gray,align=center,font=\scriptsize\itshape] at (2.south) {{\upshape\sbfamily Teilbaum 2}\\(mit Wurzel 2)};}\endpgfinterruptboundingbox}}%
\only<8|handout:0>{\tree{[9,w[15,w[8,m]][2,w[7,w][3,w][4,w]][3,w[9,w][2,w]]]}}%
\only<9|handout:0>{\tree{[9,w[15,w[8,w]][2,w[7,m][3,w][4,w]][3,w[9,w][2,w]]]}}%
\only<10-11|handout:3>{\tree{[9,w[15,w[8,w]][2,w[7,w][3,m,name=2][4,w]][3,w[9,w,name=9][2,w]]]\pgfinterruptboundingbox\onslide<11|handout:3>{\node[below=1.25mm,font=\sbfamily,paletteA] (dk) at(2.south) {Knoten};\node[below=-4pt,gray,font=\scriptsize\itshape] at (dk.south) {Ohne Teilbäume};}\endpgfinterruptboundingbox}}%
\only<12|handout:0>{\tree{[9,w[15,w[8,w]][2,w[7,w][3,w][4,m]][3,w[9,w][2,w]]]}}%
\only<13|handout:0>{\tree{[9,w[15,w[8,w]][2,w[7,w][3,w][4,w]][3,w[9,m][2,w]]]}}%
\only<14|handout:0>{\tree{[9,w[15,w[8,w]][2,w[7,w][3,w][4,w]][3,w[9,w][2,m]]]}}%
\onlyenv<16-|handout:4>\vspace*{4em}\begin{itemize}
\itemsep=10pt
\item<16-> Binärbäume: \textit{linker} und \textit{rechter} Teilbaum
\item<17-> \textit{Fehlende} Teilbäume heißen auch \textit{leer}
\item<18-> Die Betrachtung wird in Java benutzt: \lstfs{9}
\actionenv<19->
\begin{plainjava}[belowskip=0pt]
class Node {
int value;
Node leftSubtree, rightSubtree;
}
\end{plainjava}
\endactionenv
\end{itemize}\endonlyenv
\begin{tikzpicture}[overlay,remember picture]
\onslide<2-6|handout:1>{%
\node[below left=.25cm,yshift=.8cm,scale=.6] (pingu) at (current page.north east) {\rotatebox[origin=c]{180}{\usebox\pinguA}};
\node[left=-2mm,scale=.6,text width=6.75cm,align=center,yshift=-.33cm] at (pingu.west) {Jeder Knoten ist Wurzel eines Teilbaums};
}
\onslide<7-10|handout:2>{%
\node[below left=.25cm,yshift=.8cm,scale=.6] (pingu) at (current page.north east) {\rotatebox[origin=c]{180}{\usebox\pinguB}};
\node[left,scale=.6,text width=6.75cm,align=center,yshift=-.33cm] at (pingu.west) {So lassen sich rekursive Regeln formulieren!};
}
\onslide<11-14|handout:3>{%
\node[below left=.25cm,yshift=.8cm,scale=.6] (pingu) at (current page.north east) {\rotatebox[origin=c]{180}{\usebox\pinguC}};
\node[left=-3mm,scale=.6,text width=6.75cm,align=center,yshift=-.75cm] at (pingu.west) {Beispielsweise:\smallskip\par \(\text{Left} < \text{Root} \leq \text{Right}\)\par \(\text{Root} = \text{Left} + \text{Right}\)};
}
\only<15-|handout:4>{\node[below left=.5cm,scale=.5] at(current page.north east) {\usebox\pinguD};}%
\onslide<1-|handout:1->
\end{tikzpicture}%
\end{frame}
\subsection{Breitendurchläufe}
\subsubsection{Level-Order}
\SidebarCite{dive:bfs-dfs}
\begin{frame}{Level-Order\quad {\footnotesize\sbfamily\color{shadeA}(Breadth-First)}}
\begin{center}
\onslide<2->{Ebene für Ebene, von links nach rechts.}
\end{center}
\vfill
\begin{columns}[c,onlytextwidth]
\column{.6\linewidth}
\centering
% ugly cheap
\only<3|handout:0>{\tree{[8,name=8[7,name=7[,phantom][3,name=3]][6,name=6[5,name=5[,phantom][,phantom]][2,name=2[4,name=4][,phantom]]]]}}%
\only<4|handout:1>{\tree{[8,g[7[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<5|handout:0>{\tree{[8[7,g[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<6|handout:0>{\tree{[8[7[,phantom][3]][6,g[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<7|handout:0>{\tree{[8[7[,phantom][3,g]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<8|handout:0>{\tree{[8[7[,phantom][3]][6[5,g[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<9|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2,g[4][,phantom]]]]}}%
\only<10|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2[4,g][,phantom]]]]}}%
\only<11|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\column{.35\linewidth}
\centering
\foreach[count=\i] \m in{8,7,6,3,5,2,4}{\onslide<\the\numexpr3+\i\relax->{\ifnum\i>1,\space\fi\m}}%
\end{columns}%
\begin{tikzpicture}[overlay, remember picture]% pingu strut
\end{tikzpicture}%
\end{frame}
\subsection{Tiefendurchläufe}
\subsubsection{Pre-Order}
\savebox\pinguA{\tikz{\pingu[cape=pingu@main!80!white,left eye angry,right eye devil]}}%
\begin{frame}{Pre-Order\quad {\footnotesize\sbfamily\color{shadeA}(Depth-First)}}
\begin{center}
\onslide<2->{Erst \textit{Wurzel}, dann Links, dann Rechts}
\end{center}
\vfill
\begin{columns}[c,onlytextwidth]
\column{.6\linewidth}
\centering
% ugly cheap
\only<4|handout:0>{\tree{[8,name=8[7,name=7[,phantom][3,name=3]][6,name=6[5,name=5[,phantom][,phantom]][2,name=2[4,name=4][,phantom]]]]}}%
\only<5|handout:1>{\tree{[8,g[7[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<6|handout:0>{\tree{[8[7,g[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<7|handout:0>{\tree{[8[7[,phantom][3,g]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<8|handout:0>{\tree{[8[7[,phantom][3]][6,g[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<9|handout:0>{\tree{[8[7[,phantom][3]][6[5,g[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<10|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2,g[4][,phantom]]]]}}%
\only<11|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2[4,g][,phantom]]]]}}%
\only<12|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\column{.35\linewidth}
\centering
\foreach[count=\i] \m in{8,7,3,6,5,2,4}{\onslide<\the\numexpr4+\i\relax->{\ifnum\i>1,\space\fi\m}}%
\end{columns}%
\begin{tikzpicture}[overlay,remember picture]
\onslide<3-|handout:1>{%
\node[below left=.25cm,yshift=.8cm,scale=.6] (pingu) at (current page.north east) {\rotatebox[origin=c]{180}{\usebox\pinguA}};
\node[left=-2mm,scale=.6,text width=6.75cm,align=center,yshift=-.33cm] at (pingu.west) {Allgemeiner: Erst Wurzel, dann Kinder};
}
\end{tikzpicture}%
\end{frame}
\subsubsection{In-Order}
\savebox\pinguA{\tikz{\pingu[eyes shiny,halo]}}%
\begin{frame}{In-Order\quad {\footnotesize\sbfamily\color{shadeA}(Depth-First)}}
\begin{center}
\onslide<2->{Erst Links, dann \textit{Wurzel}, dann Rechts}
\end{center}
\vfill
\begin{columns}[c,onlytextwidth]
\column{.6\linewidth}
\centering
% ugly cheap
\only<3|handout:0>{\tree{[8,name=8[7,name=7[,phantom][3,name=3]][6,name=6[5,name=5[,phantom][,phantom]][2,name=2[4,name=4][,phantom]]]]}}%
\only<4|handout:1>{\tree{[8[7,g[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<5|handout:0>{\tree{[8[7[,phantom][3,g]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<6|handout:0>{\tree{[8,g[7[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<7|handout:0>{\tree{[8[7[,phantom][3]][6[5,g[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<8|handout:0>{\tree{[8[7[,phantom][3]][6,g[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<9|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2[4,g][,phantom]]]]}}%
\only<10|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2,g[4][,phantom]]]]}}%
\only<11|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\column{.35\linewidth}
\centering
\foreach[count=\i] \m in{7,3,8,5,6,4,2}{\onslide<\the\numexpr3+\i\relax->{\ifnum\i>1,\space\fi\m}}%
\end{columns}%
\begin{tikzpicture}[overlay,remember picture]
\onslide<11-|handout:1>{%
\node[below left=.25cm,yshift=.8cm,scale=.6] (pingu) at (current page.north east) {\rotatebox[origin=c]{180}{\usebox\pinguA}};
}
\end{tikzpicture}%
\end{frame}
\subsubsection{Post-Order}
\savebox\pinguA{\tikz{\pingu[eyes shock,crown=pingu@silver,crown gem colors={paletteD!85!black}{paletteB!85!black}{paletteC!85!black}{paletteA!85!black}{paletteC!85!black}{paletteB!85!black}{paletteD!85!black},heart=gray!20!white]}}%
\begin{frame}{Post-Order\quad {\footnotesize\sbfamily\color{shadeA}(Depth-First)}}
\begin{center}
\onslide<2->{Erst Links, dann Rechts, dann \textit{Wurzel}}
\end{center}
\vfill
\begin{columns}[c,onlytextwidth]
\column{.6\linewidth}
\centering
% ugly cheap
\only<4|handout:0>{\tree{[8,name=8[7,name=7[,phantom][3,name=3]][6,name=6[5,name=5[,phantom][,phantom]][2,name=2[4,name=4][,phantom]]]]}}%
\only<5|handout:1>{\tree{[8[7[,phantom][3,g]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<6|handout:0>{\tree{[8[7,g[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<7|handout:0>{\tree{[8[7[,phantom][3]][6[5,g[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<8|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2[4,g][,phantom]]]]}}%
\only<9|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2,g[4][,phantom]]]]}}%
\only<10|handout:0>{\tree{[8[7[,phantom][3]][6,g[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<11|handout:0>{\tree{[8,g[7[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\only<12|handout:0>{\tree{[8[7[,phantom][3]][6[5[,phantom][,phantom]][2[4][,phantom]]]]}}%
\column{.35\linewidth}
\centering
\foreach[count=\i] \m in{3,7,5,4,2,6,8}{\onslide<\the\numexpr4+\i\relax->{\ifnum\i>1,\space\fi\m}}%
\end{columns}%
\begin{tikzpicture}[overlay,remember picture]
\onslide<3-|handout:1>{%
\node[below left=.25cm,yshift=.8cm,scale=.6] (pingu) at (current page.north east) {\rotatebox[origin=c]{180}{\usebox\pinguA}};
\node[left=-2mm,scale=.6,text width=6.75cm,align=center,yshift=-.33cm] at (pingu.west) {Allgemeiner: Erst Kinder, dann Wurzel};
}
\end{tikzpicture}%
\end{frame}
\SidebarReset
\subsection{Kommentare}
\begin{frame}{Kommentare\hfill\textcolor{shadeA}{\textbf{I}}}
\begin{itemize}[<+(1)->]
\item Die Reihenfolge ist \textit{keine} eindeutige Beschreibung!
\begin{center}
\vspace*{1.75em}
\onslide<3->{\textit{In-Order}: 7, 6, 9, 2\medskip\\}
\null\hfill\onslide<4->{\scalebox{.66}{\tree{[9[6[7][,phantom]][2]]}}}\hfill\onslide<5->{\scalebox{.66}{\tree{[6[7][2[9][,phantom]]]}}}\hfill\onslide<6->{\scalebox{.66}{\tree{[7[,phantom][9[6][2]]]}}}\hfill\null
\end{center}
\end{itemize}
\end{frame}
\begin{frame}{Kommentare\hfill\textcolor{shadeA}{\textbf{II}}}
\begin{itemize}
\itemsep10pt
\item<2-> Es gibt auch \say{reverse}-Varianten.\smallskip\par
\onslide<3->{Diese bearbeiten den rechten \textit{vor} dem linken Teilbaum}
\item<4-> Es werden Breiten- und Tiefendurchläufe unterschieden: \medskip\begin{itemize}
\itemsep8pt
\item<5-> \textit{depth-first}:\par Bearbeitet Pfad komplett und dann Abzweigungen
\item<6-> \textit{breadth-first}:\par Breitet sich über alle Abzweigungen gleichmäßig aus
\end{itemize}
\end{itemize}
\end{frame}
% TODO: am Ende noch mal übersicht was breadth- und was depth-first ist
\section{Graphen}
\subsection{Breitendurchlauf}
\begin{frame}{Graphen in der Breite}
\begin{itemize}
\item<2-> \only<2->{\textbf}{Breiten-} und Tiefendurchläufe gehen auch auf Graphen!\medskip
\begin{center}
\vfill
\scalebox{.865}{\onslide<3->{\begin{tikzpicture}[lblob/.append style={minimum width=2.5em}]
\node[lblob,alt=<4|handout:0>{fill=shadeA,draw=shadeA,font=\sbfamily}{fill=shadeB,draw=shadeB,font=\normalfont},alt=<5-|handout:1->{fill=shadeGray,draw=shadeGray,opacity=.5}] (13) at(0,0) {13};
\node[lblob,T={4}{5|handout:1}{6-|handout:2-}] (7) at(1.5,1.5) {7};
\node[lblob,T={4-5|handout:1}{6|handout:0}{7-|handout:2-}] (8) at(1.5,0) {8};
\node[lblob,T={4-6|handout:1}{7|handout:0}{8-|handout:2-}] (25) at(1.5,-1.5) {25};
\node[lblob,T={5-7|handout:1}{8|handout:0}{9-|handout:2-}] (x2) at(3,1.5) {-2};
\node[lblob,T={8-10|handout:2}{11|handout:0}{12-|handout:3-}] (15) at(3,3) {15};
\node[lblob,T={14|handout:0}{15|handout:3-}{16|handout:0}] (10) at(9,0) {10};
\node[lblob,T={7-9|handout:2}{10|handout:0}{11-|handout:3-}] (4) at(3,-1.5) {4};
\node[lblob,T={7-8|handout:0}{9|handout:2}{10-|handout:3-}] (6) at(4.5,0) {6};
\node[lblob,T={8-11|handout:2}{12|handout:0}{13-|handout:3-}] (7b) at(6,1) {7};
\node[lblob,T={10-12|handout:0}{13|handout:0}{14-|handout:3-}] (0) at(6,-1) {0};
\node[lblob,T={12-13|handout:0}{14|handout:0}{15-|handout:3-}] (9) at(7.5,0) {9};
\onslide<2->{\node[below left,xshift=4mm,text width=7.75cm,scale=.75] at (current bounding box.north east) {{\sbfamily Queue-Buffer:}\smallskip\\{}[\,\only<3|handout:0>{\mb{13}}\only<4|handout:0>{\textcolor{gray}{13,} \mb{7}, 8, 25}\only<5|handout:1>{\textcolor{gray}{13, 7,} \mb{8}, 25, -2}\only<6|handout:0>{\textcolor{gray}{13, 7, 8,} \mb{25}, -2}\only<7|handout:0>{\textcolor{gray}{13, 7, 8, 25,} \mb{-2}, 6, 4}\only<8|handout:0>{\textcolor{gray}{13, 7, 8, 25, -2,} \mb{6}, 4, 15, 7$_2$}\only<9|handout:2>{\textcolor{gray}{13, 7, 8, 25, -2, 6,} \mb{4}, 15, 7$_2$}\only<10|handout:0>{\textcolor{gray}{13, 7, 8, 25, -2, 6, 4,} \mb{15}, 7$_2$, 0}\only<11|handout:0>{\textcolor{gray}{13, 7, 8, 25, -2, 6, 4, 15,} \mb{7$_2$}, 0}\only<12|handout:0>{\textcolor{gray}{13, 7, 8, 25, -2, 6, 4, 15, 7$_2$,} \mb{0}, 9}\only<13|handout:0>{\textcolor{gray}{13, 7, 8, 25, -2, 6, 4, 15, 7$_2$, 0,} \mb{9}}\only<14|handout:0>{\textcolor{gray}{13, 7, 8, 25, -2, 6, 4, 15, 7$_2$, 0, 9,} \mb{10}}\only<15-|handout:3->{\textcolor{gray}{13, 7, 8, 25, -2, 6, 4, 15, 7$_2$, 0, 9, 10}}\,]};}
\begin{scope}[every path/.append style={draw,line width=3pt,lgray,line cap=butt},every new ->/.style={-{Kite[scale=.75]}},every new <->/.style={{Kite[scale=.75]}-{Kite[scale=.75]}}]
\graph{%
(13) <->[K={4-5|handout:1}{0|handout:0}{6-|handout:2-}] (7) ->[K={5|handout:1}{0|handout:0}{6-|handout:2-}] (x2) ->[K={8|handout:0}{0|handout:0}{9-|handout:2-}] (6) ->[K={9|handout:2}{0|handout:0}{10-|handout:3-}] (7b) ->[K={12|handout:0}{0|handout:0}{13-|handout:3-}] (9) ->[K={14|handout:0}{0|handout:0}{15-|handout:3-}] (0) ->[K={13|handout:0}{0|handout:0}{14-|handout:3-}] (7b),
(0) ->[K={13|handout:0}{0|handout:0}{14-|handout:3-}] (6) <->[K={9-10|handout:2}{0|handout:0}{11-|handout:3-}] (4) ->[K={10|handout:0}{0|handout:0}{11-|handout:3-}] (8) ->[K={6|handout:0}{0|handout:0}{7-|handout:2-}] (25) ->[K={7|handout:0}{0|handout:0}{8-|handout:2-}] (4), (9) ->[K={14|handout:0}{0|handout:0}{15-|handout:3-}] (10),
(x2) ->[K={8|handout:0}{0|handout:0}{9-|handout:2-}] (15),
(13) ->[K={4|handout:0}{0|handout:0}{5-|handout:1-}] (8) <->[K={6|handout:0}{0|handout:0}{7|handout:0},K={8|handout:0}{0|handout:0}{9-|handout:2-}] (x2),
(13) ->[K={4|handout:0}{0|handout:0}{5-|handout:1-}] (25) ->[bend left=15,K={7|handout:0}{0|handout:0}{8-|handout:2-}] (6),
(x2) ->[bend left,K={8|handout:0}{0|handout:0}{9-|handout:2-}] (7b),
(4) <->[bend right,K={10|handout:0}{0|handout:0}{11-12|handout:3-},K={13|handout:0}{0|handout:0}{14-|handout:3-}] (0)
};
\end{scope}
\end{tikzpicture}}}
\end{center}
\end{itemize}
\begin{tikzpicture}[overlay,remember picture]% strut buf
\end{tikzpicture}%
\end{frame}
\subsection{Tiefendurchlauf}
\savebox\pinguA{\tikz{\pingu[pants=paletteD,cup=paletteA,eyes wink]}}%
\savebox\pinguB{\tikz{\pingu[eyes shiny,medal,left wing raise,sign post left={\faExclamation},hair=paletteA]}}%
\begin{frame}{Graphen in der Tiefe}
\begin{itemize}
\item<2-> Breiten- und \only<2->{\textbf}{Tiefendurchläufe} gehen auch auf Graphen!\medskip
\begin{center}
\vfill% TODO: Animation for bfs and dfs on sepearate slides
\scalebox{.865}{\onslide<3->{\begin{tikzpicture}[lblob/.append style={minimum width=2.5em}]
\node[lblob,alt=<4|handout:0>{fill=shadeA,draw=shadeA,font=\sbfamily}{fill=shadeB,draw=shadeB,font=\normalfont},alt=<5-|handout:1->{fill=shadeGray,draw=shadeGray,opacity=.5}] (13) at(0,0) {13};
\node[lblob,T={4|handout:0}{5|handout:0}{6-|handout:1-}] (7) at(1.5,1.5) {7};
\node[lblob,T={4-12|handout:1-2}{13|handout:0}{14-|handout:3-}] (8) at(1.5,0) {8};
\node[lblob,T={4-14|handout:1-2}{15|handout:3}{16-|handout:4-}] (25) at(1.5,-1.5) {25};
\node[lblob,T={5|handout:0}{6|handout:0}{7-|handout:1-}] (x2) at(3,1.5) {-2};
\node[lblob,T={6|handout:0}{7|handout:1}{8-|handout:2-}] (15) at(3,3) {15};
\node[lblob,T={9|handout:2}{10|handout:0}{11-|handout:3-}] (10) at(9,0) {10};
\node[lblob,T={13|handout:0}{14|handout:0}{15-|handout:3-}] (4) at(3,-1.5) {4};
\node[lblob,T={6-11|handout:1-2}{12|handout:0}{13-|handout:3-}] (6) at(4.5,0) {6};
\node[lblob,T={6-7|handout:1}{8|handout:0}{9-|handout:2-}] (7b) at(6,1) {7};
\node[lblob,T={8-10|handout:2}{11|handout:0}{12-|handout:3-}] (0) at(6,-1) {0};
\node[lblob,T={8|handout:0}{9|handout:2}{10-|handout:3-}] (9) at(7.5,0) {9};
\onslide<2->{\node[below left,xshift=4mm,,text width=7.75cm,scale=.75] at (current bounding box.north east) {{\sbfamily Stack-Buffer:}\smallskip\\{}[\,\only<3|handout:0>{\mb{13}}\only<4|handout:0>{25, 8, \mb{7}}\only<5|handout:0>{25, 8, \mb{-2}}\only<6|handout:0>{25, 8, 6, 7$_2$, \mb{15}}\only<7|handout:1>{25, 8, 6, \mb{7$_2$}}\only<8|handout:0>{25, 8, 6, 0, \mb{9}}\only<9|handout:2>{25, 8, 6, 0, \mb{10}}\only<10|handout:0>{25, 8, 6, \mb{0}}\only<11|handout:0>{25, 8, \mb{6}}\only<12|handout:0>{25, \mb{8}}\only<13|handout:0>{25, \mb{4}}\only<14|handout:0>{\mb{25}}\only<15|handout:3->{}\,] \hfill\only<4-|handout:1->{\textcolor{gray}{(\only<4|handout:0>{13}\only<5|handout:0>{13, 7}\only<6|handout:0>{13, 7, -2}\only<7|handout:1>{13, 7, -2, 15}\only<8|handout:0>{13, 7, -2, 15, 7$_2$}\only<9|handout:2>{13, 7, -2, 15, 7$_2$, 9}\only<10|handout:0>{13, 7, -2, 15, 7$_2$, 9, 10}\only<11|handout:0>{13, 7, -2, 15, 7$_2$, 9, 10, 0}\only<12|handout:0>{13, 7, -2, 15, 7$_2$, 9, 10, 0, 6}\only<13|handout:0>{13, 7, -2, 15, 7$_2$, 9, 10, 0, 6, 8}\only<14|handout:0>{13, 7, -2, 15, 7$_2$, 9, 10, 0, 6, 8, 4}\only<15-|handout:3->{13, 7, -2, 15, 7$_2$, 9, 10, 0, 6, 8, 4, 25})}}};}
\begin{scope}[every path/.append style={draw,line width=3pt,lgray,line cap=butt},every new ->/.style={-{Kite[scale=.75]}},every new <-/.style={{Kite[scale=.75]}-},every new <->/.style={{Kite[scale=.75]}-{Kite[scale=.75]}}]
\graph{%
(13) <->[K={4-5|handout:0}{0|handout:0}{6-|handout:1-}] (7) ->[K={5|handout:0}{0|handout:0}{6-|handout:1-}] (x2) ->[K={6|handout:0}{0|handout:0}{7-|handout:1-}] (6) ->[K={12|handout:0}{0|handout:0}{13-|handout:3-}] (7b) ->[K={8|handout:0}{0|handout:0}{9-|handout:2-}] (9) ->[K={9|handout:2}{0|handout:0}{10-|handout:3-}] (0) <-[K={8|handout:0}{0|handout:0}{9-|handout:2-}] (7b),
(0) <-[K={12|handout:0}{0|handout:0}{13-|handout:3-}] (6) <-[K={14|handout:0}{0|handout:0}{15-|handout:3-}] (4) <-[K={13|handout:0}{0|handout:0}{14-|handout:3-}] (8) ->[K={13|handout:0}{0|handout:0}{14-|handout:3-}] (25) ->[K={15|handout:3}{0|handout:0}{16-|handout:4-}] (4), (9) ->[K={9|handout:2}{0|handout:0}{10-|handout:3-}] (10),
(x2) ->[K={6|handout:0}{0|handout:0}{7-|handout:1-}] (15),
(13) ->[K={4|handout:0}{0|handout:0}{5-|handout:1-}] (8) <->[K={6|handout:0}{0|handout:0}{7-12|handout:0},K={13|handout:0}{0|handout:0}{14-|handout:1-}] (x2),
(13) ->[K={4|handout:0}{0|handout:0}{5-|handout:1-}] (25) ->[bend left=15,K={15|handout:3}{0|handout:0}{16-|handout:4-}] (6),
(x2) ->[bend left,K={6|handout:0}{0|handout:0}{7-|handout:1-}] (7b),
(4) ->[bend right,K={14|handout:0}{0|handout:0}{15-|handout:3-}] (0)
};
\end{scope}
\end{tikzpicture}}}
\end{center}
\end{itemize}%
\begin{tikzpicture}[overlay,remember picture]
\onslide<16-|handout:1->{%
\node[below left=.25cm,yshift=.8cm,scale=.6] (pingu) at (current page.north east) {\rotatebox[origin=c]{180}{\usebox\pinguA}};
\node[left=-2mm,scale=.6,text width=6.75cm,align=center,yshift=-.33cm] at (pingu.west) {\textit{Achtung:} Zur Anschaulichkeit habe ich ein paar Kanten abgeändert!};
}
\onslide<17-|handout:2->{%
\node[above right=.33cm,scale=.65,yshift=.5cm] (pingu) at (current page.south west) {\usebox\pinguB};
\node[gray,above=1mm,text width=3.5cm,scale=.8,align=center,font=\scriptsize] at(pingu.north) {%
Die Reihenfolge, mit der die Kinder auf den Stack kommen, hängt natürlich von der Implementation ab!%
};}
\end{tikzpicture}%
\end{frame}
\section{Labyrinthe}
\savebox\pinguA{\tikz{\pingu[eyes shock, wings shock]}}%
\savebox\pinguB{\tikz{\pingu[left eye shiny,silver medal,left wing raise,sign post left={\faHeart},hair=paletteB,monocle right]}}%
\begin{frame}{Irrgärten}
\begin{itemize}[<+(1)->]
\item Ein Labyrinth ist auch nur ein cooler Graph\bigskip
\begin{center}
\onslide<4->{\begin{tikzpicture}
\Matrix{%
{X,X,X,X,X,X,X,X,X,X},
{X,1-4|handout:0/5|handout:1/6-|handout:2-,5|handout:1/6|handout:0/7-|handout:2-,6-7|handout:0/8|handout:0/9-|handout:2-,8-9|handout:0/10|handout:0/11-|handout:2-,10-12|handout:2/13|handout:0/14-|handout:3-,X,20-21|handout:0/22|handout:0/23-|handout:4-,22-23|handout:4/24|handout:0/25-|handout:5-,X},
{X,5-6|handout:1/7|handout:0/8-|handout:2-,X,8-10|handout:0/11|handout:0/12-|handout:2-,10-13|handout:2/14|handout:0/15-|handout:3-,X,X,19|handout:0/20|handout:0/21-|handout:4-,X,X},
{X,7-8|handout:0/9|handout:0/10-|handout:2-,X,X,14-15|handout:0/16|handout:3/17-|handout:4-,16|handout:3/17|handout:0/18-|handout:4-,17|handout:0/18|handout:0/19-|handout:4-,18|handout:0/19|handout:0/20-|handout:4-,X,X},
{X,9-11|handout:0/12|handout:2/13-|handout:3-,12-14|handout:2/15|handout:0/16-|handout:3-,X,X,X,X,19-20|handout:0/21|handout:0/22-|handout:4-,X,X},
{X,X,X,X,27|handout:0/28|handout:5/29-|handout:0,26|handout:0/27|handout:0/28-|handout:5-,23-25|handout:4/26|handout:0/27-|handout:5-,21-22|handout:0/23|handout:4/24-|handout:5-,23-24|handout:4/25|handout:0/26-|handout:5-,X},%
{X,X,X,X,X,X,X,X,X,X}%
}{10}{7}% TRIGGER:
{5}{12}{16}{23}{-1}{-1}
\end{tikzpicture}}
\end{center}
\end{itemize}
\vspace*{-4.33mm}\smash{\begin{tikzpicture}[overlay,remember picture]
\onslide<3-|handout:1->{%
\node[below left=.25cm,yshift=.8cm,scale=.6] (pingu) at (current page.north east) {\rotatebox[origin=c]{180}{\usebox\pinguA}};
\node[left=1mm,scale=.9,yshift=-.33cm] at (pingu.west) {Mazes Exposed!!!!};
}
\onslide<4->{
\node[above right=.33cm,scale=.65,yshift=.5cm] (pingu) at (current page.south west) {\usebox\pinguB};
\node[gray,above=1mm,text width=3.5cm,scale=.8,align=center,font=\scriptsize] at(pingu.north) {%
Bei dieser beispielhaften Breitensuche darf der Läufer nicht diagonal gehen!%
};
}
\end{tikzpicture}}%
\end{frame}
\subsection{Breitendurchlauf}
\savebox\pinguB{\tikz{\pingu[left eye wink,bronze medal,left wing raise,sign post left={\faStar},hair=paletteC,monocle left, eye patch right]}}%
\begin{frame}{Ein Breitendurchlauf}
\begin{itemize}[<+(1)->]
\item Ein einfaches \say{Labyrinth} und viel AHA:\bigskip
\begin{center}
\onslide<3->{\begin{tikzpicture}
\Matrix{%
{X,X,X,X,X,X,X,X,X,X},
{X,1-3|handout:0/4|handout:1/5-|handout:2-,4|handout:1/5|handout:0/6-|handout:2-,5-7|handout:0/8|handout:0/9-|handout:2-,8-12|handout:0/13|handout:2/14-|handout:3-,13-19|handout:2-3/20|handout:0/21-|handout:4-,20-23|handout:0/24|handout:0/25-|handout:4-,24-25|handout:0/26|handout:0/27-|handout:4-,26-27|handout:0/28|handout:0/29-|handout:4-,X},
{X,4-6|handout:1/7|handout:0/8-|handout:2-,4-5|handout:1/6|handout:0/7-|handout:2-,5-8|handout:0/9|handout:0/10-|handout:2-,8-13|handout:2/14|handout:0/15-|handout:3-,X,X,X,X,X},
{X,6-11|handout:0/12|handout:0/13-|handout:2-,6-10|handout:0/11|handout:0/13-|handout:2-,6-9|handout:0/10|handout:0/11-|handout:2-,9-14|handout:2/15|handout:0/16-|handout:3-,X,X,X,X,X},
{X,11-18|handout:2/19|handout:3/20-|handout:4-,10-17|handout:2/18|handout:0/19-|handout:3-,10-16|handout:2/17|handout:0/18-|handout:3-,10-15|handout:2/16|handout:0/17-|handout:3-,15-20|handout:3/21|handout:0/22-|handout:4-,21-24|handout:0/25|handout:0/26-|handout:4-,25-26|handout:0/27|handout:0/28-|handout:4-,27-28|handout:0/29|handout:4/30-|handout:5-,X},
{X,18-22|handout:3/23|handout:0/24-|handout:4-,X,X,16-21|handout:3/22|handout:0/23-|handout:4-,X,X,X,X,X},
{X,X,X,X,X,X,X,X,X,X}%
}{10}{7}% TRIGGER:
{4}{13}{19}{29}{-1}{-1}
\end{tikzpicture}}
\end{center}
\end{itemize}
\vspace*{-4.33mm}\smash{\begin{tikzpicture}[overlay,remember picture]
\onslide<3->{
\node[above right=.33cm,scale=.65,yshift=.5cm] (pingu) at (current page.south west) {\usebox\pinguB};
\node[gray,above=1mm,text width=3.5cm,scale=.8,align=center,font=\scriptsize] at(pingu.north) {%
Hier darf der Läufer diagonal gehen!%
};
}
\end{tikzpicture}}%
\end{frame}
\subsection{Tiefendurchlauf}
\savebox\pinguB{\tikz{\pingu[left eye shiny,right eye wink,bronze medal,left wing raise,sign post left={\faInfo},hair=paletteD,monocle right]}}%
\begin{frame}{Ein Tiefendurchlauf}
\begin{itemize}[<+(1)->]
\item Ein einfaches \say{Labyrinth} und viel AHA:\bigskip
\begin{center}
\onslide<3->{\begin{tikzpicture}
\Matrix{%
{X,X,X,X,X,X,X,X,X,X},
{X,1-3|handout:0/4|handout:1/5-|handout:2-,4|handout:1/5|handout:0/6-|handout:2-,5|handout:0/6|handout:0/7-|handout:2-,6|handout:0/7|handout:0/8-|handout:2-,7|handout:0/8|handout:0/9-|handout:2-,8|handout:0/9|handout:0/10-|handout:2-,9|handout:0/10|handout:0/11-|handout:2-,10|handout:0/11|handout:2/12-|handout:3-,X},
{X,4-24|handout:1-4/25|handout:0/26-|handout:5-,4-25|handout:1-4/26|handout:0/27-|handout:5-,5-26|handout:2-4/27|handout:0/28-|handout:5-,6-11|handout:2/12|handout:0/13-|handout:3-,X,X,X,X,X},
{X,21-23|handout:0/24|handout:0/25-|handout:5-,20-28|handout:4/29|handout:5/30-|handout:6-,12-27|handout:3-4/28|handout:0/29-|handout:5-,12|handout:0/13|handout:0/14-|handout:3-,X,X,X,X,X},
{X,21|handout:0/22|handout:0/23-|handout:5-,20|handout:4/21|handout:0/22-|handout:5-,13-19|handout:3/20|handout:4/21-|handout:5-,13|handout:0/14|handout:3/15-|handout:4-,13-15|handout:3/16|handout:0/17-|handout:4-,16|handout:0/17|handout:0/18-|handout:4-,17|handout:0/18|handout:0/19-|handout:4-,18|handout:0/19|handout:0/20-|handout:4-,X},
{X,21-22|handout:0/23|handout:0/24-|handout:5-,X,X,14|handout:3/15|handout:0/16-|handout:4-,X,X,X,X,X},
{X,X,X,X,X,X,X,X,X,X}%
}{10}{7}% TRIGGER:
{4}{11}{14}{20}{29}{-1}
\end{tikzpicture}}
\end{center}
\end{itemize}
\vspace*{-4.33mm}\smash{\begin{tikzpicture}[overlay,remember picture]
\onslide<3->{
\node[above right=.33cm,scale=.65,yshift=.5cm] (pingu) at (current page.south west) {\usebox\pinguB};
\node[gray,above=1mm,text width=3.5cm,scale=.8,align=center,font=\scriptsize] at(pingu.north) {%
Hier darf der Läufer diagonal gehen!%
};
}
\end{tikzpicture}}%
\end{frame}
\section{Abschluss}
\SidebarCite{dive:traverse}
\SidebarCite{dive:planning}
\SidebarCite{dive:path-games}
\begin{frame}{Abschließendes}
\begin{itemize}[<+(1)->]
\itemsep12pt
\item Dies war ein primär visueller Blick auf Traversierungen
\item Es gibt vieeel mehr (z.B. die \say{Wirbeltraversierung})
\item Die Kenntnis über die iterative und rekursive Implementation ist nützlich!
\item Breiten- \& Tiefensuche helfen auch bei der Wegfindung
\end{itemize}
\end{frame}
\SidebarReset
% TODO: wirbeltraversierung
\end{document}