| 325 |      1 | % !TEX program = xelatex
 | 
| 66 |      2 | \documentclass[dvipsnames,14pt,t,xelatex]{beamer}
 | 
|  |      3 | \usepackage{../slides}
 | 
|  |      4 | \usepackage{../graphics}
 | 
|  |      5 | \usepackage{../langs}
 | 
| 155 |      6 | %%\usepackage{../data}
 | 
| 67 |      7 | \usepackage[export]{adjustbox}
 | 
| 222 |      8 | \usetikzlibrary{shapes}
 | 
| 66 |      9 | 
 | 
|  |     10 | \hfuzz=220pt 
 | 
|  |     11 | 
 | 
|  |     12 | %\setmonofont[Scale=.88]{Consolas}
 | 
|  |     13 | %\newfontfamily{\consolas}{Consolas}
 | 
|  |     14 | 
 | 
|  |     15 | \lstset{language=Scala,
 | 
|  |     16 |         style=mystyle,
 | 
|  |     17 |         numbersep=0pt,
 | 
|  |     18 |         numbers=none,
 | 
|  |     19 |         xleftmargin=0mm}
 | 
|  |     20 | 
 | 
| 222 |     21 | \newcommand{\LEFTarrow}[3]{%
 | 
|  |     22 | \begin{textblock}{0}(#2,#3)%
 | 
|  |     23 | \onslide<#1>{%
 | 
|  |     24 | \begin{tikzpicture}%
 | 
|  |     25 | \node at (0,0) [single arrow, shape border rotate=180, fill=red,text=red]{a};%
 | 
|  |     26 | \end{tikzpicture}}%
 | 
|  |     27 | \end{textblock}}
 | 
|  |     28 | \newcommand{\DOWNarrow}[3]{%
 | 
|  |     29 | \begin{textblock}{0}(#2,#3)%
 | 
|  |     30 | \onslide<#1>{%
 | 
|  |     31 | \begin{tikzpicture}%
 | 
|  |     32 | \node at (0,0) [single arrow, shape border rotate=270, fill=red,text=red]{a};%
 | 
|  |     33 | \end{tikzpicture}}%
 | 
|  |     34 | \end{textblock}}
 | 
|  |     35 | 
 | 
|  |     36 | 
 | 
| 66 |     37 | \newcommand{\bl}[1]{\textcolor{blue}{#1}}     
 | 
|  |     38 | 
 | 
|  |     39 | % beamer stuff 
 | 
| 222 |     40 | \renewcommand{\slidecaption}{PEP (Scala) 04, King's College London}
 | 
| 66 |     41 | 
 | 
| 155 |     42 | \begin{filecontents}{re3a.data}
 | 
|  |     43 | 1 0.00003
 | 
|  |     44 | 500001 0.22527
 | 
|  |     45 | 1000001 0.62752
 | 
|  |     46 | 1500001 0.88485
 | 
|  |     47 | 2000001 1.39815
 | 
|  |     48 | 2500001 1.68619
 | 
|  |     49 | 3000001 1.94957
 | 
|  |     50 | 3500001 2.15878
 | 
|  |     51 | 4000001 2.59918
 | 
|  |     52 | 4500001 5.90679
 | 
|  |     53 | 5000001 13.11295
 | 
|  |     54 | 5500001 19.15376
 | 
|  |     55 | 6000001 40.16373
 | 
|  |     56 | \end{filecontents}
 | 
|  |     57 | \begin{filecontents}{re-python2.data}
 | 
|  |     58 | 1 0.033
 | 
|  |     59 | 5 0.036
 | 
|  |     60 | 10 0.034
 | 
|  |     61 | 15 0.036
 | 
|  |     62 | 18 0.059
 | 
|  |     63 | 19 0.084
 | 
|  |     64 | 20 0.141
 | 
|  |     65 | 21 0.248
 | 
|  |     66 | 22 0.485
 | 
|  |     67 | 23 0.878
 | 
|  |     68 | 24 1.71
 | 
|  |     69 | 25 3.40
 | 
|  |     70 | 26 7.08
 | 
|  |     71 | 27 14.12
 | 
|  |     72 | 28 26.69
 | 
|  |     73 | \end{filecontents}
 | 
|  |     74 | 
 | 
| 222 |     75 | \begin{filecontents}{re-js.data}
 | 
|  |     76 | 5   0.061
 | 
|  |     77 | 10  0.061
 | 
|  |     78 | 15  0.061
 | 
|  |     79 | 20  0.070
 | 
|  |     80 | 23  0.131
 | 
|  |     81 | 25  0.308
 | 
|  |     82 | 26  0.564
 | 
|  |     83 | 28  1.994
 | 
|  |     84 | 30  7.648
 | 
|  |     85 | 31  15.881 
 | 
|  |     86 | 32  32.190
 | 
|  |     87 | \end{filecontents}
 | 
|  |     88 | 
 | 
| 155 |     89 | \begin{filecontents}{re-java.data}
 | 
|  |     90 | 5  0.00298
 | 
|  |     91 | 10  0.00418
 | 
|  |     92 | 15  0.00996
 | 
|  |     93 | 16  0.01710
 | 
|  |     94 | 17  0.03492
 | 
|  |     95 | 18  0.03303
 | 
|  |     96 | 19  0.05084
 | 
|  |     97 | 20  0.10177
 | 
|  |     98 | 21  0.19960
 | 
|  |     99 | 22  0.41159
 | 
|  |    100 | 23  0.82234
 | 
|  |    101 | 24  1.70251
 | 
|  |    102 | 25  3.36112
 | 
|  |    103 | 26  6.63998
 | 
|  |    104 | 27  13.35120
 | 
|  |    105 | 28  29.81185
 | 
|  |    106 | \end{filecontents}
 | 
| 66 |    107 | 
 | 
| 222 |    108 | \begin{filecontents}{re-java9.data}
 | 
|  |    109 | 1000  0.01410
 | 
|  |    110 | 2000  0.04882
 | 
|  |    111 | 3000  0.10609
 | 
|  |    112 | 4000  0.17456
 | 
|  |    113 | 5000  0.27530
 | 
|  |    114 | 6000  0.41116
 | 
|  |    115 | 7000  0.53741
 | 
|  |    116 | 8000  0.70261
 | 
|  |    117 | 9000  0.93981
 | 
|  |    118 | 10000 0.97419
 | 
|  |    119 | 11000 1.28697
 | 
|  |    120 | 12000 1.51387
 | 
|  |    121 | 14000 2.07079
 | 
|  |    122 | 16000 2.69846
 | 
|  |    123 | 20000 4.41823
 | 
|  |    124 | 24000 6.46077
 | 
|  |    125 | 26000 7.64373
 | 
|  |    126 | 30000 9.99446
 | 
|  |    127 | 34000 12.966885
 | 
|  |    128 | 38000 16.281621
 | 
|  |    129 | 42000 19.180228
 | 
|  |    130 | 46000 21.984721
 | 
|  |    131 | 50000 26.950203
 | 
|  |    132 | 60000 43.0327746
 | 
|  |    133 | \end{filecontents}
 | 
|  |    134 | 
 | 
|  |    135 | 
 | 
| 66 |    136 | \begin{document}
 | 
|  |    137 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    138 | \begin{frame}[t]
 | 
|  |    139 | \frametitle{%
 | 
|  |    140 |   \begin{tabular}{@ {}c@ {}}
 | 
|  |    141 |   \\[5mm]
 | 
| 222 |    142 |   \huge PEP Scala (4) 
 | 
| 66 |    143 |   \end{tabular}}
 | 
|  |    144 | 
 | 
|  |    145 |   \normalsize
 | 
|  |    146 |   \begin{center}
 | 
|  |    147 |   \begin{tabular}{ll}
 | 
| 155 |    148 |     Email:  & christian.urban at kcl.ac.uk\\
 | 
| 325 |    149 |     Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\
 | 
|  |    150 |     Slides \& Code: & KEATS\\
 | 
| 326 |    151 |                     & \onslide<2>{\alert{PDF: A Crash-Course in Scala}}\bigskip\\
 | 
| 325 |    152 |     Office Hours: &  Thursdays 12:00 -- 14:00\\
 | 
|  |    153 |     Additionally: & (for Scala) Tuesdays 10:45 -- 11:45\\ 
 | 
| 66 |    154 |   \end{tabular}
 | 
|  |    155 |   \end{center}
 | 
|  |    156 | 
 | 
|  |    157 | 
 | 
|  |    158 | \end{frame}
 | 
|  |    159 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    160 | 
 | 
| 325 |    161 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 222 |    162 | \begin{frame}[c]
 | 
| 325 |    163 | \frametitle{Hints in CW}
 | 
| 222 |    164 | 
 | 
| 325 |    165 | \begin{center}  
 | 
|  |    166 | \includegraphics[scale=0.4]{../pics/hints.png}
 | 
| 222 |    167 | \end{center}
 | 
|  |    168 | 
 | 
| 325 |    169 | \small
 | 
|  |    170 | \begin{itemize}
 | 
|  |    171 |   \item Scala Library, e.g.~\texttt{span} in \\
 | 
|  |    172 |   \url{https://www.scala-lang.org/api/current/scala/collection/immutable/List.html}
 | 
|  |    173 | \end{itemize}
 | 
|  |    174 | \end{frame}
 | 
|  |    175 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    176 |   
 | 
| 326 |    177 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    178 | \begin{frame}[c]
 | 
|  |    179 | \frametitle{Discussion Forum}
 | 
| 222 |    180 | 
 | 
| 326 |    181 | \begin{center}  
 | 
|  |    182 | \includegraphics[scale=0.38]{/Users/cu/discussion.png}
 | 
|  |    183 | \end{center}
 | 
|  |    184 | 
 | 
|  |    185 | \end{frame}
 | 
|  |    186 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 222 |    187 | 
 | 
|  |    188 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
| 325 |    189 | \begin{frame}[c]
 | 
|  |    190 | \frametitle{Preliminary 7}
 | 
| 222 |    191 | 
 | 
| 325 |    192 | Raw marks (261 submissions):\bigskip
 | 
| 222 |    193 | 
 | 
| 325 |    194 | \begin{itemize}
 | 
|  |    195 | \item 4\%: \hspace{4mm}236
 | 
|  |    196 | \item 3\%: \hspace{4mm}10
 | 
|  |    197 | \item 2\%: \hspace{4mm}1
 | 
|  |    198 | \item 1\%: \hspace{4mm}0
 | 
|  |    199 | \item 0\%: \hspace{4mm}15 
 | 
|  |    200 | \end{itemize}\bigskip\bigskip  
 | 
| 222 |    201 | 
 | 
| 325 |    202 | \footnotesize
 | 
| 326 |    203 | (plagiarism/collusion interviews ongoing!)
 | 
| 222 |    204 | 
 | 
|  |    205 | \end{frame}
 | 
|  |    206 | 
 | 
|  |    207 | 
 | 
|  |    208 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 66 |    209 | 
 | 
| 325 |    210 | 
 | 
| 66 |    211 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 67 |    212 | \begin{frame}[c,fragile]
 | 
| 222 |    213 | \small
 | 
|  |    214 |   
 | 
| 325 |    215 | \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
 | 
|  |    216 | def is_legal(dim: Int, p: Path, x: Pos) = {
 | 
|  |    217 |   if (...some_really_long_condition...) false
 | 
| 222 |    218 |   else true
 | 
|  |    219 | }
 | 
|  |    220 | \end{lstlisting}
 | 
| 67 |    221 | 
 | 
| 222 |    222 | \pause
 | 
|  |    223 | \bigskip
 | 
|  |    224 | \rule{11cm}{0.3mm}
 | 
|  |    225 | \bigskip
 | 
|  |    226 | 
 | 
| 325 |    227 | \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
 | 
|  |    228 | def is_legal(dim: Int, p: Path, x: Pos) = 
 | 
|  |    229 |   !(...some_really_long_condition...)
 | 
|  |    230 | \end{lstlisting}
 | 
|  |    231 | 
 | 
|  |    232 | \end{frame}
 | 
|  |    233 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    234 | 
 | 
|  |    235 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    236 | \begin{frame}[c,fragile]
 | 
|  |    237 | \small
 | 
|  |    238 |   
 | 
|  |    239 | \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
 | 
|  |    240 | def foobar(...) = {
 | 
|  |    241 |   val cs = for (c <- str) yield c.toLowerCase
 | 
|  |    242 |   ...
 | 
|  |    243 | }
 | 
|  |    244 | \end{lstlisting}
 | 
|  |    245 | 
 | 
|  |    246 | \pause
 | 
|  |    247 | \bigskip
 | 
|  |    248 | \rule{11cm}{0.3mm}
 | 
|  |    249 | \bigskip
 | 
|  |    250 | 
 | 
|  |    251 | \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
 | 
|  |    252 | def foobar(...) = {
 | 
|  |    253 |   val cs = str.map(_.toLowerCase)
 | 
|  |    254 |   ...
 | 
|  |    255 | }
 | 
|  |    256 | \end{lstlisting}
 | 
|  |    257 | 
 | 
|  |    258 | \end{frame}
 | 
|  |    259 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    260 | 
 | 
|  |    261 | 
 | 
|  |    262 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    263 | \begin{frame}[c,fragile]
 | 
|  |    264 | \small
 | 
|  |    265 |   
 | 
| 222 |    266 | \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-7mm]
 | 
| 325 |    267 | def RomanNumeral2Int(rs: RomanNumeral): Int = 
 | 
|  |    268 |  rs match { 
 | 
|  |    269 |    case Nil => 0
 | 
|  |    270 |    case M::r    => 1000 + RomanNumeral2Int(r)  
 | 
|  |    271 |    case C::M::r => 900 + RomanNumeral2Int(r)
 | 
|  |    272 |    case D::r    => 500 + RomanNumeral2Int(r)
 | 
|  |    273 |    case C::D::r => 400 + RomanNumeral2Int(r)
 | 
|  |    274 |    case C::r    => 100 + RomanNumeral2Int(r)
 | 
|  |    275 |    case X::C::r => 90 + RomanNumeral2Int(r)
 | 
|  |    276 |    case L::r    => 50 + RomanNumeral2Int(r)
 | 
|  |    277 |    case X::L::r => 40 + RomanNumeral2Int(r)
 | 
|  |    278 |    case X::r    => 10 + RomanNumeral2Int(r)
 | 
|  |    279 |    case I::X::r => 9 + RomanNumeral2Int(r)
 | 
|  |    280 |    case V::r    => 5 + RomanNumeral2Int(r)
 | 
|  |    281 |    case I::V::r => 4 + RomanNumeral2Int(r)
 | 
|  |    282 |    case I::r    => 1 + RomanNumeral2Int(r)
 | 
|  |    283 |  }
 | 
|  |    284 | \end{lstlisting}
 | 
| 67 |    285 | 
 | 
|  |    286 | \end{frame}
 | 
|  |    287 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    288 | 
 | 
|  |    289 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 325 |    290 | \begin{frame}[c,fragile]
 | 
|  |    291 | \frametitle{Last Week: Pattern Matching} 
 | 
|  |    292 | \small
 | 
|  |    293 |   
 | 
|  |    294 | \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=3mm]
 | 
|  |    295 | def fizz_buzz(n: Int) : String = 
 | 
|  |    296 |   (n % 3, n % 5) match {
 | 
|  |    297 |     case (0, 0) => "fizz buzz"
 | 
|  |    298 |     case (0, _) => "fizz"
 | 
|  |    299 |     case (_, 0) => "buzz"
 | 
|  |    300 |     case _ => n.toString  
 | 
|  |    301 |   }
 | 
|  |    302 | \end{lstlisting}
 | 
|  |    303 | 
 | 
|  |    304 | \end{frame}
 | 
|  |    305 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    306 | 
 | 
|  |    307 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    308 | \begin{frame}[c,fragile]
 | 
|  |    309 | \frametitle{Reverse Polish Notation}
 | 
|  |    310 | 
 | 
|  |    311 | {\Large\bl{$(3 + 1) * (2 + 9)$}}\bigskip
 | 
|  |    312 | 
 | 
|  |    313 | {\Large$\Rightarrow$}\bigskip
 | 
|  |    314 | 
 | 
|  |    315 | {\;\;\Large\bl{$3\;\;1\;+\;2\;\;9\;+\;*$}}
 | 
|  |    316 | 
 | 
|  |    317 | \begin{textblock}{3}(11,4)
 | 
|  |    318 | \begin{onlyenv}<2>
 | 
|  |    319 | \begin{lstlisting}[language=JVMIS]
 | 
|  |    320 | ldc 3
 | 
|  |    321 | ldc 1
 | 
|  |    322 | iadd
 | 
|  |    323 | ldc 2
 | 
|  |    324 | ldc 9
 | 
|  |    325 | iadd
 | 
|  |    326 | imul
 | 
|  |    327 | \end{lstlisting}
 | 
|  |    328 | \end{onlyenv} 
 | 
|  |    329 | \end{textblock}
 | 
|  |    330 | 
 | 
|  |    331 | \end{frame}
 | 
|  |    332 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    333 |  
 | 
|  |    334 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    335 | \begin{frame}[c,fragile]
 | 
|  |    336 | \frametitle{Sudoku}
 | 
|  |    337 | 
 | 
|  |    338 | A very simple-minded version on 110 problems:\bigskip
 | 
|  |    339 | 
 | 
|  |    340 | \begin{itemize}
 | 
|  |    341 | \item 1 core: 800 secs
 | 
|  |    342 | \item 2 cores: 400 secs
 | 
|  |    343 | \item 8 cores: 290 secs
 | 
|  |    344 | \item 18 cores: 142 secs
 | 
|  |    345 | \end{itemize}
 | 
|  |    346 | 
 | 
|  |    347 | \end{frame}
 | 
|  |    348 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    349 |  
 | 
|  |    350 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 222 |    351 | \begin{frame}[c]
 | 
|  |    352 | \frametitle{DFAs}  
 | 
|  |    353 | 
 | 
|  |    354 | \begin{center}
 | 
|  |    355 | \begin{tikzpicture}[>=stealth',very thick,auto,
 | 
|  |    356 |   every state/.style={minimum size=0pt,inner sep=2pt,
 | 
|  |    357 |     draw=blue!50,very thick,fill=blue!20},]
 | 
|  |    358 |   
 | 
|  |    359 | \only<1,3->{\node[state,initial] (Q_0)  {$\mbox{Q}_0$};}
 | 
|  |    360 | \only<2>{\node[state,initial,fill=red] (Q_0)  {$\mbox{Q}_0$};}  
 | 
|  |    361 | \only<1,2,4->{\node[state] (Q_1) [right=of Q_0] {$\mbox{Q}_1$};}
 | 
|  |    362 | \only<3>{\node[state,fill=red] (Q_1) [right=of Q_0] {$\mbox{Q}_1$};}
 | 
|  |    363 | \only<-3,5->{\node[state] (Q_2) [below right=of Q_0] {$\mbox{Q}_2$};}
 | 
|  |    364 | \only<4>{\node[state,fill=red] (Q_2) [below right=of Q_0] {$\mbox{Q}_2$};}
 | 
|  |    365 | \only<-4,6->{\node[state] (Q_3) [right=of Q_2] {$\mbox{Q}_3$};}
 | 
|  |    366 | \only<5>{\node[state,fill=red] (Q_3) [right=of Q_2] {$\mbox{Q}_3$};}
 | 
|  |    367 | \only<-5>{\node[state, accepting] (Q_4) [right=of Q_1] {$\mbox{Q}_4$};}
 | 
|  |    368 | \only<6->{\node[state, accepting,fill=red] (Q_4) [right=of Q_1] {$\mbox{Q}_4$};}
 | 
|  |    369 | 
 | 
|  |    370 | \path[->] (Q_0) edge node [above]  {\alert{$a$}} (Q_1);
 | 
|  |    371 | \path[->] (Q_1) edge node [above]  {\alert{$a$}} (Q_4);
 | 
|  |    372 | \path[->] (Q_4) edge [loop right] node  {\alert{$a, b$}} ();
 | 
|  |    373 | \path[->] (Q_3) edge node [right]  {\alert{$a$}} (Q_4);
 | 
|  |    374 | \path[->] (Q_2) edge node [above]  {\alert{$a$}} (Q_3);
 | 
|  |    375 | \path[->] (Q_1) edge node [right]  {\alert{$b$}} (Q_2);
 | 
|  |    376 | \path[->] (Q_0) edge node [above]  {\alert{$b$}} (Q_2);
 | 
|  |    377 | \path[->] (Q_2) edge [loop left] node  {\alert{$b$}} ();
 | 
|  |    378 | \path[->] (Q_3) edge [bend left=95, looseness=1.3] node [below]  {\alert{$b$}} (Q_0);
 | 
|  |    379 | \end{tikzpicture}
 | 
|  |    380 | \end{center}
 | 
| 67 |    381 | 
 | 
| 222 |    382 | \begin{textblock}{9}(4,12)
 | 
|  |    383 | \LARGE{}
 | 
|  |    384 | \only<3->{\boldmath\alert{$a$}}%
 | 
|  |    385 | \only<4->{\boldmath\alert{$b$}}%
 | 
|  |    386 | \only<5->{\boldmath\alert{$a$}}%
 | 
|  |    387 | \only<6->{\boldmath\alert{$a$}}%
 | 
|  |    388 | \only<7->{\boldmath\alert{$a\quad\Rightarrow \textbf{yes}$}}% 
 | 
|  |    389 | \end{textblock}
 | 
|  |    390 |   
 | 
|  |    391 | \end{frame}
 | 
|  |    392 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    393 | 
 | 
|  |    394 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    395 | \begin{frame}[t]
 | 
|  |    396 | \frametitle{DFAs}
 | 
| 67 |    397 | 
 | 
| 222 |    398 | A \alert{\bf deterministic finite automaton}, DFA, consists of
 | 
|  |    399 | 5 things:
 | 
|  |    400 | 
 | 
|  |    401 | \begin{itemize}
 | 
|  |    402 | \item an alphabet \bl{$\varSigma$}  
 | 
|  |    403 | \item a set of states \bl{$\mbox{Qs}$}
 | 
|  |    404 | \item one of these states is the start state \bl{$\mbox{Q}_0$}
 | 
|  |    405 | \item some states are accepting states \bl{$F$}, and
 | 
|  |    406 | \item there is transition function \bl{$\delta$}\bigskip 
 | 
|  |    407 | 
 | 
|  |    408 | \small
 | 
|  |    409 | which takes a state  and a character as arguments and produces a 
 | 
|  |    410 | new state; this function might not be everywhere defined 
 | 
|  |    411 | \end{itemize}
 | 
|  |    412 | 
 | 
|  |    413 | \begin{center}
 | 
|  |    414 | \bl{$A(\varSigma, \mbox{Qs}, \mbox{Q}_0, F, \delta)$}
 | 
|  |    415 | \end{center}
 | 
| 67 |    416 | 
 | 
|  |    417 | \end{frame}
 | 
| 222 |    418 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    419 | 
 | 
|  |    420 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    421 | \begin{frame}[c]
 | 
|  |    422 | \frametitle{NFAs}  
 | 
| 67 |    423 | 
 | 
| 222 |    424 | \begin{center}
 | 
|  |    425 | \begin{tikzpicture}[>=stealth',very thick, auto,
 | 
|  |    426 |     every state/.style={minimum size=0pt,inner sep=3pt,
 | 
|  |    427 |       draw=blue!50,very thick,fill=blue!20},scale=2]
 | 
|  |    428 | \node[state,initial]  (Q_0)  {$\mbox{Q}_0$};
 | 
|  |    429 | \node[state] (Q_1) [right=of Q_0] {$\mbox{Q}_1$};
 | 
|  |    430 | \node[state, accepting] (Q_2) [right=of Q_1] {$\mbox{Q}_2$};
 | 
|  |    431 | \path[->] (Q_0) edge [loop above] node  {\alert{$b$}} ();
 | 
|  |    432 | \path[<-] (Q_0) edge node [below]  {\alert{$b$}} (Q_1);
 | 
|  |    433 | \path[->] (Q_0) edge [bend left] node [above]  {\alert{$a$}} (Q_1);
 | 
|  |    434 | \path[->] (Q_0) edge [bend right=45,looseness=1.3] node [below]  {\alert{$a$}} (Q_2);
 | 
|  |    435 | \path[->] (Q_1) edge [loop above] node  {\alert{$a,b$}} ();
 | 
|  |    436 | \path[->] (Q_1) edge node  [above] {\alert{$a$}} (Q_2);
 | 
|  |    437 | \end{tikzpicture}
 | 
|  |    438 | \end{center}
 | 
|  |    439 | 
 | 
|  |    440 | \end{frame}
 | 
|  |    441 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
| 68 |    442 | 
 | 
| 155 |    443 | 
 | 
| 325 |    444 | 
 | 
|  |    445 | \begin{frame}[t]
 | 
|  |    446 | 
 | 
|  |    447 |   \begin{center}  
 | 
|  |    448 |   \includegraphics[scale=0.3]{../pics/blow.png}
 | 
|  |    449 |   \end{center}
 | 
|  |    450 |   
 | 
|  |    451 |   \begin{textblock}{14}(2,11.4)
 | 
|  |    452 |   \large\bf{}Mind-Blowing Regular Expressions:\\ 
 | 
|  |    453 |   \centering in Python, JavaScript, Java
 | 
|  |    454 |   \end{textblock}
 | 
|  |    455 | \end{frame}
 | 
| 67 |    456 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 325 |    457 | 
 | 
|  |    458 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    459 | \begin{frame}[c,fragile]
 | 
|  |    460 | \frametitle{Regular Expressions} 
 | 
|  |    461 |   
 | 
| 326 |    462 | Suppose you have the regular expression 
 | 
| 325 |    463 | \only<1-3>{\alert{\texttt{(a*)b}}}%
 | 
|  |    464 | \only<4->{\alert{\texttt{(a*)*b}}} :\bigskip
 | 
|  |    465 | 
 | 
|  |    466 | \begin{center}
 | 
|  |    467 | \only<1>{\code{"aaaaaaaaaaaaaaab"}}
 | 
|  |    468 | \only<2>{\code{"aaaaa...........aaaaaaaaaaaaaaaaaaaab"}}
 | 
|  |    469 | \only<3>{\code{"aaaaa...........aaaaaaaaaaaaaaaaaaaa"}}
 | 
|  |    470 | \only<4>{\code{"aaaaa...........aaaaaaaaaaaaaaaaaaaab"}}
 | 
|  |    471 | \only<5->{\code{"aaaaa...........aaaaaaaaaaaaaaaaaaaa"}}
 | 
|  |    472 | \end{center}
 | 
|  |    473 | 
 | 
|  |    474 | \only<6>{
 | 
|  |    475 | \begin{textblock}{13}(5,12)
 | 
|  |    476 | How long does Python need to find out?
 | 
|  |    477 | \end{textblock}}
 | 
|  |    478 | 
 | 
|  |    479 | \end{frame}
 | 
|  |    480 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    481 | 
 | 
|  |    482 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    483 | \begin{frame}<1>[c]
 | 
|  |    484 |   \frametitle{CW 9: Regexes}
 | 
| 68 |    485 |   
 | 
|  |    486 | \begin{center}
 | 
| 325 |    487 |   Graphs: \alert{\texttt{(a*)*b}} and strings $\underbrace{\;\texttt{a}\ldots \texttt{a}\;}_{n}$\bigskip
 | 
| 68 |    488 |   
 | 
|  |    489 | \begin{tabular}[t]{@{\hspace{-8mm}}c@{\hspace{-4mm}}c@{}}
 | 
| 222 |    490 | \only<1>{\raisebox{6mm}{\begin{tikzpicture}
 | 
| 68 |    491 | \begin{axis}[
 | 
|  |    492 |     xlabel={$n$},
 | 
|  |    493 |     x label style={at={(1.05,0.0)}},
 | 
|  |    494 |     ylabel={time in secs},
 | 
|  |    495 |     enlargelimits=false,
 | 
|  |    496 |     xtick={0,5,...,30},
 | 
|  |    497 |     xmax=33,
 | 
|  |    498 |     ymax=35,
 | 
|  |    499 |     ytick={0,5,...,30},
 | 
|  |    500 |     scaled ticks=false,
 | 
|  |    501 |     axis lines=left,
 | 
|  |    502 |     width=5.5cm,
 | 
|  |    503 |     height=5cm, 
 | 
| 222 |    504 |     legend entries={\small{}Python,  \small{}Java 8,  \small{}JavaScript},  
 | 
| 68 |    505 |     legend pos=north west,
 | 
|  |    506 |     legend cell align=left]
 | 
|  |    507 | \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};  
 | 
|  |    508 | \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
 | 
| 222 |    509 | \addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
 | 
| 68 |    510 | \end{axis}
 | 
| 222 |    511 | \end{tikzpicture}}}%
 | 
|  |    512 | \only<2>{\raisebox{0mm}{\begin{tikzpicture}
 | 
|  |    513 | \begin{axis}[
 | 
|  |    514 |     xlabel={$n$},
 | 
|  |    515 |     x label style={at={(1.05,0.0)}},
 | 
|  |    516 |     ylabel={time in secs},
 | 
|  |    517 |     %y label style={at={(0.06,0.5)}},
 | 
|  |    518 |     enlargelimits=false,
 | 
|  |    519 |     %xtick={0,30000,...,60000},
 | 
|  |    520 |     xmax=65000,
 | 
|  |    521 |     ymax=35,
 | 
|  |    522 |     ytick={0,5,...,30},
 | 
|  |    523 |     scaled ticks=true,
 | 
|  |    524 |     axis lines=left,
 | 
|  |    525 |     width=5.5cm,
 | 
|  |    526 |     height=5cm, 
 | 
|  |    527 |     legend entries={\small{}Java 9},  
 | 
|  |    528 |     legend pos=north west]
 | 
|  |    529 | \addplot[cyan,mark=*, mark options={fill=white}] table {re-java9.data};
 | 
|  |    530 | \end{axis}
 | 
|  |    531 | \end{tikzpicture}}}
 | 
| 68 |    532 |   &
 | 
| 222 |    533 | \onslide<1-2>{\begin{tikzpicture}
 | 
| 68 |    534 |   \begin{axis}[
 | 
|  |    535 |     xlabel={$n$},
 | 
|  |    536 |     x label style={at={(1.05,0.0)}},
 | 
|  |    537 |     ylabel={time in secs},
 | 
|  |    538 |     enlargelimits=false,
 | 
|  |    539 |     ymax=35,
 | 
|  |    540 |     ytick={0,5,...,30},
 | 
|  |    541 |     axis lines=left,
 | 
|  |    542 |     %%scaled ticks=false,
 | 
|  |    543 |     width=5.5cm, 
 | 
|  |    544 |     height=5cm]
 | 
|  |    545 | %%\addplot[green,mark=square*,mark options={fill=white}] table {re2a.data};    
 | 
| 222 |    546 | \addplot[magenta,mark=square*,mark options={fill=white}] table {re3a.data};
 | 
| 68 |    547 | \end{axis}
 | 
| 70 |    548 | \end{tikzpicture}}
 | 
| 68 |    549 | \end{tabular}
 | 
|  |    550 | \end{center}
 | 
| 66 |    551 | 
 | 
| 68 |    552 | \hfill\small\url{https://vimeo.com/112065252}
 | 
| 66 |    553 | \end{frame}
 | 
| 325 |    554 | 
 | 
|  |    555 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 67 |    556 | 
 | 
| 325 |    557 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
| 68 |    558 | \begin{frame}[c]
 | 
| 67 |    559 | 
 | 
| 222 |    560 | \begin{center}
 | 
| 325 |    561 |   \includegraphics[angle=90,scale=0.35]{/Users/cu/vote.pdf}
 | 
| 222 |    562 | \end{center}
 | 
| 326 |    563 |  
 | 
|  |    564 |  \only<2>{%
 | 
|  |    565 | \begin{textblock}{13}(10,10)
 | 
|  |    566 | \includegraphics[scale=0.2]{/Users/cu/goodvote.png}
 | 
|  |    567 | \end{textblock}}
 | 
| 67 |    568 | 
 | 
|  |    569 | \end{frame}
 | 
| 325 |    570 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
| 67 |    571 | 
 | 
| 325 |    572 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    573 | \begin{frame}[c]
 | 
|  |    574 | 
 | 
|  |    575 | \begin{center}
 | 
|  |    576 |   \includegraphics[scale=0.25]{/Users/cu/dresden.png}
 | 
|  |    577 | \end{center}
 | 
| 67 |    578 | 
 | 
| 325 |    579 | \begin{textblock}{13}(2,12)
 | 
|  |    580 | \includegraphics[scale=0.08]{/Users/cu/kiss.jpg}
 | 
|  |    581 | \end{textblock}
 | 
|  |    582 | 
 | 
|  |    583 | \begin{textblock}{13}(6.8,12)
 | 
|  |    584 | \includegraphics[scale=0.079]{/Users/cu/pioniere.jpg}
 | 
|  |    585 | \end{textblock}
 | 
|  |    586 | 
 | 
|  |    587 | \begin{textblock}{13}(11,12)
 | 
|  |    588 | \includegraphics[scale=0.20]{/Users/cu/iron.jpg}
 | 
|  |    589 | \end{textblock}
 | 
|  |    590 | 
 | 
|  |    591 | \DOWNarrow{1}{11}{8.6}
 | 
| 66 |    592 | 
 | 
|  |    593 | \end{frame}
 | 
| 325 |    594 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    595 | 
 | 
| 70 |    596 | 
 | 
| 66 |    597 | 
 | 
|  |    598 | 
 | 
|  |    599 | \end{document}
 | 
|  |    600 | 
 | 
|  |    601 | %%% Local Variables:  
 | 
|  |    602 | %%% mode: latex
 | 
|  |    603 | %%% TeX-master: t
 | 
|  |    604 | %%% End: 
 | 
|  |    605 | 
 |