-
Notifications
You must be signed in to change notification settings - Fork 0
/
Notes_CSE105.tex
492 lines (429 loc) · 13.7 KB
/
Notes_CSE105.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
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
%%***********************************************
%% Setups
%%***********************************************
\documentclass[12pt, letterpaper, titlepage]{article}
% \setlength{\columnsep}{31pt} % space b/w columns;
% margins
\usepackage[top=.5in, bottom=1.2in, left=.7in, right=.7in]{geometry}
% title
\title{\Huge CSE 105: \\ Computation
\\[-1em] \rule{.8\textwidth}{1pt}
}
\author{\LARGE{\it by} Jy}
\date{}
%\thanks{}
%***********************************************
% Graphs
%***********************************************
%% space of caption and the context;
% \setlength{\abovecaptionskip}{10pt}
% \setlength{\belowcaptionskip}{15pt}
%\usepackage{subfigure}
\usepackage{graphicx}
\graphicspath{{pics/}}
%% figures with text wrapped around;
%\usepackage{wrapfig}
%\usepackage{picins}
\usepackage{tikz}
% \usetikzlibrary{arrows}
%%\usepackage{tkz-euclide}
%\usepackage{pgfplots}
% \tikzset{
% myvec/.style={blue, line width = .5pt, -stealth'},
% every node/.style={black},
% box/.style={rectangle, rounded corners=5pt,
% minimum width=30pt, minimum height=15pt,
% inner sep=5pt,
% draw=silver, fill=lightpurple},
% }
% trees
\usepackage{tikz-qtree}
% \usepackage{pst-tree}
%% set wallpaper
%\usepackage{wallpaper}
% \CenterWallPaper{1}{}
%% Include movies
%\usepackage{media9}
%% use colors
\usepackage{xcolor}
\definecolor{lightblue}{RGB}{39, 104, 192}
\definecolor{silver}{RGB}{200,191,231}
\definecolor{lightpurple}{RGB}{200,200,240}
%%***********************************************
%% Tables
%%***********************************************
% linestrech in arrays/tables
\renewcommand{\arraystretch}{1.2}
%% tables w/ wrapped lines;
%\usepackage{tabularx}
% \newcommand{\ahsize}[1]{ \setlength{\hsize}{#1\hsize} }
% \newcommand{\bhsize}[1]{ \setlength{\hsize}{#1} }
%% sideways
\usepackage{rotating}
%% makecell
%\usepackage{makecell}
% \makegapedcells
% \setcellgapes{6pt}
%% color for tables;
%\usepackage{colortbl}
%% toprule, midrule & bottomrule;
%\usepackage{booktabs}
\usepackage{array} %解决前置命令问题;
\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
\newcolumntype{C}[1]{>{\PreserveBackslash\centering}p{#1}}
\newcolumntype{R}[1]{>{\PreserveBackslash\raggedleft}p{#1}}
\newcolumntype{L}[1]{>{\PreserveBackslash\raggedright}p{#1}}
\newcolumntype{M}[1]{>{$}#1<{$}}
%% multirow;
\usepackage{multirow}
%% long table + tabularx;
%\usepackage{ltxtable, filecontents}
%%***********************************************
%% Coding
%%***********************************************
% \usepackage{listings}
% \lstset{
% language=C++,
% breaklines=true, %自动换行;
% extendedchars=false, %这一条命令可以解决代码跨页时,章节标题,页眉等汉字不显示的问题;
% numbers=left,
% numberstyle=\scriptsize,
% stepnumber=2, %行标跳过数;
% numbersep=1.5em, %行标与代码框距离;
% tabsize=4,
% basicstyle=\footnotesize\ttfamily,
% stringstyle=\color{lightblue},
% keywordstyle=\color{blue!80},
% commentstyle=\color{red!70!green!70!blue!90},
% frame=shadowbox,
%% showspaces=false,
% showstringspaces=false,
% showtabs=false,
% rulesepcolor=\color{red!20!green!20!blue!20},
% backgroundcolor=\color{red!10!green!3!blue!10},
% escapeinside=``,
% xleftmargin=8em,
% xrightmargin=5em,
% framexleftmargin=2pt,
% framexrightmargin=2pt,
% aboveskip=1em
% }
% \renewcommand{\lstlistingname}{CODE}
%***********************************************
% Fonts
%***********************************************
%% English;
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Times New Roman}
\setsansfont[Mapping=tex-text]{Calibri}
\setmonofont{Courier New}
% \newfontfamily\rh{Lucida Handwriting} % rh for Round Handing
% \newfontfamily\sc{John Handy LET} % sc for script
% \newfontfamily\hw{Bradley Hand ITC} % hw for HandWritting
%% Chinese;
%\usepackage[CJKchecksingle, CJKnumber]{xeCJK}
% \setCJKmainfont[BoldFont = {STXingkai}, ItalicFont = {STFangsong}]{Microsoft YaHei}
% \setCJKsansfont{}
% \setCJKmonofont{KaiTi}
% \punctstyle{hangmobanjiao}
%\newcommand{\CJKdash}{\rule[3.5pt]{9pt}{.77pt} \hspace{-1.5mm} \rule[3.5pt]{9pt}{.77pt} }
%%***********************************************
%% Looking
%%***********************************************
%% links
\usepackage[bookmarksnumbered, pdfencoding=auto, pdfborder=1, breaklinks,
colorlinks, linkcolor=lightblue, urlcolor=blue]{hyperref}
\hypersetup{
unicode=false, % non-Latin characters in Acrobat’s bookmarks
pdftoolbar=true, % show Acrobat toolbar?
pdfmenubar=true, % show Acrobat menu?
pdftitle={}, % title
pdfauthor={Jinyao Yuan},% author
pdfsubject={}, % subject of the document
pdfcreator={Jinyao Yuan}, % creator of the document
pdfproducer={Jinyao Yuan}, % producter of the document
citecolor=green, % color of links to bibliography
filecolor=magenta, % color of file links
}
%% page style
%%---------------------------------------------------------------------------
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\lfoot{}
\cfoot{}
\rfoot{\thepage}
%% paragraphs
%%---------------------------------------------------------------------------
\usepackage{setspace}
\onehalfspacing
% \doublespacing
\setlength{\parindent}{2em}
\addtolength{\parskip}{3pt}
\usepackage{indentfirst}
%% floats
%%---------------------------------------------------------------------------
% \renewcommand{\textfraction}{0.15}
% \renewcommand{\topfraction}{0.85}
% \renewcommand{\bottomfraction}{0.65}
\renewcommand{\floatpagefraction}{0.70}
\usepackage[section]{placeins}
% \usepackage[below]{placeins}
\usepackage{caption}
%% underline
%%---------------------------------------------------------------------------
\usepackage{ulem}
%\usepackage{CJKfntef}
%% emphasis
%%---------------------------------------------------------------------------
% \DeclareTextFontCommand{\emshape}{\itshape}
\def\emshape{\itshape}
\makeatletter
\DeclareRobustCommand{\em}{%
\@nomath\em \if b\expandafter\@car\f@series\@nil \normalfont
\else \emshape \fi
}
\makeatother
\DeclareTextFontCommand{\emph}{\em}
%% convert terms into Chinese;
%%---------------------------------------------------------------------------
%\renewcommand{\contentsname}{\hfill 目~录 \hfill}
%\renewcommand{\listfigurename}{图目录}
%\renewcommand{\listtablename}{表目录}
%\renewcommand{\thepart}{\CJKnumber{\arabic{part}}}
%\renewcommand{\partname}{第\CJKnumber{\thepart}章}
%\renewcommand{\thesection}{\CJKnumber{\arabic{section}}}
%\newcommand{\sectionname}{\thesection 节}
%\renewcommand{\figurename}{图}
%\renewcommand{\figureautorefname}{图}
%\renewcommand{\tablename}{表}
%\renewcommand{\tableautorefname}{表}
%\renewcommand {\thefootnote}{\arabic{footnote}}
%\renewcommand{\footnoteautorefname}{脚注}
%\renewcommand{\abstractname}{摘 \quad 要}
%\renewcommand{\appendixname}{附录{\thechapter}}
%\renewcommand{\appendixautorefname}{附录}
%\renewcommand{\bibname}{参考文献}
%\renewcommand{\indexname}{索引}
%% make own style of section titles;
%%---------------------------------------------------------------------------
\usepackage{titlesec}
% \titleformat{\part}{\center\Huge \bf}{\thepart}{1em}{}
% \titleformat{\section}{\large \bf}{\thesection}{1em}{}
\titleformat{\part}[frame]{\normalfont}
{\small \enspace UNIT \thepart \enspace}{6pt}
{\LARGE\bf\filcenter}
\titlespacing*{\part}{1pc}{*4}{*3}[1pc]
\newcommand{\mypart}{\FloatBarrier\part}
%% make own style of table of contents;
%%---------------------------------------------------------------------------
%\usepackage{titletoc}
%\titlecontents{part}[0em]{\addvspace{10pt}\filright\bf\large}
% {\def\numberline##1{\thecontentslabel\quad\ignorespaces}}
% {}{\titlerule*[8pt]{.}\contentspage}
%\titlecontents{section}[1em]{\addvspace{10pt}\filright\bf\large}
% {\def\numberline##1{\thecontentslabel\quad\ignorespaces}}
% {}{\titlerule*[8pt]{.}\contentspage}
%\titlecontents{subsection}[2em]{\addvspace{5pt}\filright\bf}
% {\def\numberline##1{\thecontentslabel\quad\ignorespaces}}
% {}{\titlerule*[8pt]{.} \contentspage}
%***********************************************
% Utilities
%***********************************************
%% in-para enum, item, descript;
%%---------------------------------------------------------------------------
\usepackage{paralist}
%% lettrine;
%%---------------------------------------------------------------------------
%\usepackage{lettrine}
% \newcommand{\mylettrine}[1]{\lettrine[lines=2,lraise=0,nindent=0em]{#1\hspace{1mm}}{}}
%% Math;
%%---------------------------------------------------------------------------
\usepackage{amsmath, amsfonts, amssymb, amsthm}
\usepackage{venndiagram}
%\usepackage{extarrows} % special arrows like \xlongequal;
%\input{longdiv.tex} % divisions;
%\usepackage{dcolumn} % vertical calculation w/ tabular;
\usepackage{cancel} % strike out numbers
%% Theorems;
%%---------------------------------------------------------------------------
\newtheoremstyle{mystyle}
{2em} % spaceabove
{2em} % spacebelow
{\it} % bodyfont
{0em} % indent
{\bf} % headfont
{} % headpunctuation
{1em} % headspace
{%
\thmname{#1} \thmnumber{#2} \thmnote{#3}.
} % headspecify
\theoremstyle{mystyle}
\newtheorem{definition}{Definition}[section]
\newtheorem{theorem}{Theorem}[section]
%% symbols
%%---------------------------------------------------------------------------
\newcommand{\phteq}{ \phantom{{}={}} }
\renewcommand{\(}{ \left( }
\renewcommand{\)}{ \right) }
\newcommand{\nth}{\ensuremath{^\text{th}}\xspace}
\newcommand{\st}{\ensuremath{^\text{st}}\xspace}
\newcommand{\nd}{\ensuremath{^\text{nd}}\xspace}
\newcommand{\rd}{\ensuremath{^\text{rd}}\xspace}
\newcommand{\dd}{{ \, \mathrm{d} }}
\newcommand{\abs}[1]{{ \left\lvert #1 \right\rvert }}
\newcommand{\set}[1]{{ \left\{\,#1\,\right\} }}
\newcommand{\lst}[1]{{ \left(\,#1\,\right) }}
%\newcommand{\dne}{ \mathrm{DNE} } % Does Not Exist;
%\newcommand{\defeq}{ \xlongequal{\mathrm{DEF}} } % equal by definition;
%\newcommand{\sqr}{ \ensuremath{^2} } % squared;
% \newcommand{\cels}{{ \ensuremath{^\circ \mathrm{C}} }}
%\newcommand{\fahr}{{ \ensuremath{^\circ \mathrm{F}} }}
\newcommand{\Conf}{{ \mathrm{Conf} }}
\newcommand{\true}{{ \text{\upshape True} }}
\newcommand{\false}{{ \text{\upshape False} }}
\newcommand{\DFA}{{ M = \lst{Q, \Sigma, \delta, s, F} }}
\newcommand{\NFA}{{ N = \lst{Q, \Sigma, \delta, s, F} }}
\newcommand{\reducable}{{ \,\le_{\text{\upshape FST}}\, }}
\newcommand{\reducableN}{{ \,\le_{\text{\upshape NFST}}\, }}
\newcommand{\reverse}{{ \mathrm{rev} }}
\newcommand{\combination}{{ \mathrm{C} }}
\newcommand{\permutation}{{ \mathrm{P} }}
\newcommand{\variance}[1]{{ \mathrm{Var}(#1) }}
\newcommand{\stirling}{{ \mathrm{S} }}
\newcommand{\powerset}{{ \mathcal{P} }}
\newcommand{\Degree}{{ \mathbb{Deg} }}
\newcommand{\degree}{{ \mathbb{deg} }}
%% visiblespace
\renewcommand\textvisiblespace[1][.5em]{%
\makebox[#1]{%
\kern.07em
\vrule height.3ex
\hrulefill
\vrule height.3ex
\kern.07em
}
}
%% fillable forms
%%---------------------------------------------------------------------------
%\newcommand{\fform}[2]{
%#1 \vbox{\hbox{\TextField[name=#1,width=#2,borderwidth=0]{\null}}\kern0pt\hrule}
%}
%% Margin notes;
%%---------------------------------------------------------------------------
\usepackage{marginnote}
\marginparsep 2em
\marginparwidth 2.5in
% fancy boxes like \fbox,\shadowbox,\doublebox,\ovalbox, \Ovalbox。
\usepackage{fancybox}
%%***********************************************
%% Self-defined environments
%%***********************************************
\usepackage{float} % used to define float environments
%% list point
%%---------------------------------------------------------------------------
%\newcommand{\lspnt}[1]{&\textrm{#1}}
%\newenvironment{pntlist} {
% $
% \left\{
% \begin{aligned}
%}{
% \end{aligned}
% \right.
% $
%}
%% centered graph
%%---------------------------------------------------------------------------
\newcommand{\centgraph}[2][.7\linewidth]{
\begin{center}
\includegraphics[width=#1]{#2}
\end{center}
}
%% questions & solutions
%%---------------------------------------------------------------------------
%\input{environment.question/quest.tex}
% shadowpage
%---------------------------------------------------------------------------
\newenvironment{shadowpage}%
{
\begin{Sbox} \begin{minipage}
}{
\end{minipage} \end{Sbox}
\setlength{\fboxsep}{10pt}
\shadowbox{\TheSbox}
}%
% examples
%---------------------------------------------------------------------------
%\floatstyle{plaintop}
%\newfloat{exp}{htb}{log}[subsection]
%\floatname{exp}{Example}
\DeclareCaptionType[%
placement=htbp,
within=section,
fileext=loe
]{myExample}[Example][List of Examples]
\newenvironment{example}[1][~]%
{%
\begin{myExample}
\hfill
\begin{Sbox}
\begin{minipage}{.8\linewidth}
\footnotesize
\vspace{-.5em} \caption{#1} ~ \\[-2em]
\rule{\linewidth}{.3pt}
\par
\setlength{\parindent}{2em}
\addtolength{\parskip}{3pt}
}{%
\end{minipage}
\end{Sbox}
\setlength{\fboxsep}{10pt}
\shadowbox{\TheSbox}
\end{myExample}
}%
%\newenvironment{example}%
%{
% \par\noindent
% \hfill
% \begin{Sbox}
% \begin{minipage}{.8\linewidth}
% \footnotesize
% {\bf Example} \\[-1em]
% \rule{\linewidth}{.5pt}
% \par
% \setlength{\parindent}{2em}
%}{
% \end{minipage}
% \end{Sbox}
% \setlength{\fboxsep}{10pt}
% \fbox{\TheSbox}
% \par
%}%
%***********************************************
% START
%***********************************************
\begin{document}
\maketitle
\pagenumbering{roman}
\tableofcontents\clearpage
\pagenumbering{arabic}
\input{lec1}
\input{lec2}
\input{lec3}
\input{lec4}
\input{lec5}
\input{lec6}
\input{lec7}
% \input{lec8}
\input{lec9}
\input{lec10}
\input{lec11}
\input{lec12}
% \input{lec13}
% \input{lec14}
\input{lec15}
\end{document}