Add second year

This commit is contained in:
2023-12-07 01:19:12 +00:00
parent 3291e5c79e
commit 3d12031ab8
1168 changed files with 431409 additions and 0 deletions

View File

@ -0,0 +1,49 @@
\relax
\providecommand\hyper@newdestlabel[2]{}
\providecommand\HyperFirstAtBeginDocument{\AtBeginDocument}
\HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined
\global\let\oldnewlabel\newlabel
\gdef\newlabel#1#2{\newlabelxx{#1}#2}
\gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}}
\AtEndDocument{\ifx\hyper@anchor\@undefined
\let\newlabel\oldnewlabel
\fi}
\fi}
\global\let\hyper@last\relax
\gdef\HyperFirstAtBeginDocument#1{#1}
\providecommand\HyField@AuxAddToFields[1]{}
\providecommand\HyField@AuxAddToCoFields[2]{}
\@writefile{toc}{\contentsline {section}{\numberline {1}Abstract Data Types}{2}{section.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Stacks \& Queues}{2}{subsection.1.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.1.1}Stacks}{2}{subsubsection.1.1.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.1.2}Queues}{2}{subsubsection.1.1.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}Linked Lists}{3}{subsection.1.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.2.1}Implementation of Linked Lists}{3}{subsubsection.1.2.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.2.2}Singly Linked List Class}{4}{subsubsection.1.2.2}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {2}Algorithm Analysis}{5}{section.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.1}Algorithm Analysis Basics}{5}{subsection.2.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {2.1.1}Counting Primitive Operations}{5}{subsubsection.2.1.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2}O Notation}{5}{subsection.2.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {2.2.1}Important Functions Used in O Notation}{6}{subsubsection.2.2.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {2.2.2}Efficiency \& O Notation}{7}{subsubsection.2.2.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.3}Recursion Review}{7}{subsection.2.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3}Dynamic Programming}{7}{section.3}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.1}More Big Greek Letters}{8}{subsection.3.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.2}P, NP, \& NP-Complete Problems}{9}{subsection.3.2}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4}Searching \& Sorting}{10}{section.4}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {4.1}Keys \& Values}{10}{subsection.4.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {4.2}Java Interface: Comparator}{10}{subsection.4.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {4.3}Java Interface: Comparable}{10}{subsection.4.3}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {4.4}Insertion Sort}{10}{subsection.4.4}\protected@file@percent }
\@writefile{loa}{\contentsline {algorithm}{\numberline {1}{\ignorespaces Insertion Sort Pseudocode}}{11}{algorithm.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {4.5}Shell Sort}{12}{subsection.4.5}\protected@file@percent }
\@writefile{loa}{\contentsline {algorithm}{\numberline {2}{\ignorespaces Shell Sort Pseudocode}}{12}{algorithm.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {4.6}Quick Sort}{12}{subsection.4.6}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {5}Trees}{13}{section.5}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1}Binary Trees}{13}{subsection.5.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2}Generics in Java}{13}{subsection.5.2}\protected@file@percent }
\bibstyle{unsrtnat}
\bibdata{references}
\@writefile{toc}{\contentsline {section}{\numberline {6}Search Trees}{14}{section.6}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {6.1}Binary Search Trees}{14}{subsection.6.1}\protected@file@percent }
\gdef \@abspage@last{15}

View File

@ -0,0 +1,700 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.4.9) 20 APR 2023 20:24
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**CT2109-Notes
(./CT2109-Notes.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-03-30>
(/opt/texlive/2023/texmf-dist/tex/latex/base/article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(/opt/texlive/2023/texmf-dist/tex/latex/base/size11.clo
File: size11.clo 2022/07/02 v1.4n Standard LaTeX file (size option)
)
\c@part=\count185
\c@section=\count186
\c@subsection=\count187
\c@subsubsection=\count188
\c@paragraph=\count189
\c@subparagraph=\count190
\c@figure=\count191
\c@table=\count192
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\bibindent=\dimen140
) (./report.sty
(/opt/texlive/2023/texmf-dist/tex/latex/geometry/geometry.sty
Package: geometry 2020/01/02 v5.9 Page Geometry
(/opt/texlive/2023/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
\KV@toks@=\toks16
)
(/opt/texlive/2023/texmf-dist/tex/generic/iftex/ifvtex.sty
Package: ifvtex 2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
(/opt/texlive/2023/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
))
\Gm@cnth=\count193
\Gm@cntv=\count194
\c@Gm@tempcnt=\count195
\Gm@bindingoffset=\dimen141
\Gm@wd@mp=\dimen142
\Gm@odd@mp=\dimen143
\Gm@even@mp=\dimen144
\Gm@layoutwidth=\dimen145
\Gm@layoutheight=\dimen146
\Gm@layouthoffset=\dimen147
\Gm@layoutvoffset=\dimen148
\Gm@dimlist=\toks17
)
(/opt/texlive/2023/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty
Package: fancyhdr 2022/11/09 v4.1 Extensive control of page headers and footers
\f@nch@headwidth=\skip50
\f@nch@O@elh=\skip51
\f@nch@O@erh=\skip52
\f@nch@O@olh=\skip53
\f@nch@O@orh=\skip54
\f@nch@O@elf=\skip55
\f@nch@O@erf=\skip56
\f@nch@O@olf=\skip57
\f@nch@O@orf=\skip58
)
\@abovecaptionskip=\skip59
\@belowcaptionskip=\skip60
)
(/opt/texlive/2023/texmf-dist/tex/latex/algorithmicx/algpseudocode.sty
Package: algpseudocode
(/opt/texlive/2023/texmf-dist/tex/latex/base/ifthen.sty
Package: ifthen 2022/04/13 v1.1d Standard LaTeX ifthen package (DPC)
)
(/opt/texlive/2023/texmf-dist/tex/latex/algorithmicx/algorithmicx.sty
Package: algorithmicx 2005/04/27 v1.2 Algorithmicx
Document Style algorithmicx 1.2 - a greatly improved `algorithmic' style
\c@ALG@line=\count196
\c@ALG@rem=\count197
\c@ALG@nested=\count198
\ALG@tlm=\skip61
\ALG@thistlm=\skip62
\c@ALG@Lnr=\count199
\c@ALG@blocknr=\count266
\c@ALG@storecount=\count267
\c@ALG@tmpcounter=\count268
\ALG@tmplength=\skip63
)
Document Style - pseudocode environments for use with the `algorithmicx' style
) (/opt/texlive/2023/texmf-dist/tex/latex/algorithms/algorithm.sty
Package: algorithm 2009/08/24 v0.1 Document Style `algorithm' - floating enviro
nment
(/opt/texlive/2023/texmf-dist/tex/latex/float/float.sty
Package: float 2001/11/08 v1.3d Float enhancements (AL)
\c@float@type=\count269
\float@exts=\toks18
\float@box=\box51
\@float@everytoks=\toks19
\@floatcapt=\box52
)
\@float@every@algorithm=\toks20
\c@algorithm=\count270
)
(/opt/texlive/2023/texmf-dist/tex/latex/base/inputenc.sty
Package: inputenc 2021/02/14 v1.3d Input encoding file
\inpenc@prehook=\toks21
\inpenc@posthook=\toks22
)
(/opt/texlive/2023/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2021/04/29 v2.0v Standard LaTeX package
LaTeX Font Info: Trying to load font information for T1+ptm on input line 11
2.
(/opt/texlive/2023/texmf-dist/tex/latex/psnfss/t1ptm.fd
File: t1ptm.fd 2001/06/04 font definitions for T1/ptm.
))
(/opt/texlive/2023/texmf-dist/tex/latex/hyperref/hyperref.sty
Package: hyperref 2023-02-07 v7.00v Hypertext links for LaTeX
(/opt/texlive/2023/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty
Package: ltxcmds 2020-05-10 v1.25 LaTeX kernel commands for general use (HO)
)
(/opt/texlive/2023/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty
Package: pdftexcmds 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO
)
(/opt/texlive/2023/texmf-dist/tex/generic/infwarerr/infwarerr.sty
Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO)
)
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
)
(/opt/texlive/2023/texmf-dist/tex/latex/kvsetkeys/kvsetkeys.sty
Package: kvsetkeys 2022-10-05 v1.19 Key value parser (HO)
)
(/opt/texlive/2023/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty
Package: kvdefinekeys 2019-12-19 v1.6 Define keys (HO)
)
(/opt/texlive/2023/texmf-dist/tex/generic/pdfescape/pdfescape.sty
Package: pdfescape 2019/12/09 v1.15 Implements pdfTeX's escape features (HO)
)
(/opt/texlive/2023/texmf-dist/tex/latex/hycolor/hycolor.sty
Package: hycolor 2020-01-27 v1.10 Color options for hyperref/bookmark (HO)
)
(/opt/texlive/2023/texmf-dist/tex/latex/letltxmacro/letltxmacro.sty
Package: letltxmacro 2019/12/03 v1.6 Let assignment for LaTeX macros (HO)
)
(/opt/texlive/2023/texmf-dist/tex/latex/auxhook/auxhook.sty
Package: auxhook 2019-12-17 v1.6 Hooks for auxiliary files (HO)
)
(/opt/texlive/2023/texmf-dist/tex/latex/hyperref/nameref.sty
Package: nameref 2022-05-17 v2.50 Cross-referencing by name of section
(/opt/texlive/2023/texmf-dist/tex/latex/refcount/refcount.sty
Package: refcount 2019/12/15 v3.6 Data extraction from label references (HO)
)
(/opt/texlive/2023/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty
Package: gettitlestring 2019/12/15 v1.6 Cleanup title references (HO)
(/opt/texlive/2023/texmf-dist/tex/latex/kvoptions/kvoptions.sty
Package: kvoptions 2022-06-15 v3.15 Key value format for package options (HO)
))
\c@section@level=\count271
)
\@linkdim=\dimen149
\Hy@linkcounter=\count272
\Hy@pagecounter=\count273
(/opt/texlive/2023/texmf-dist/tex/latex/hyperref/pd1enc.def
File: pd1enc.def 2023-02-07 v7.00v Hyperref: PDFDocEncoding definition (HO)
Now handling font encoding PD1 ...
... no UTF-8 mapping file for font encoding PD1
)
(/opt/texlive/2023/texmf-dist/tex/generic/intcalc/intcalc.sty
Package: intcalc 2019/12/15 v1.3 Expandable calculations with integers (HO)
)
(/opt/texlive/2023/texmf-dist/tex/generic/etexcmds/etexcmds.sty
Package: etexcmds 2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
)
\Hy@SavedSpaceFactor=\count274
(/opt/texlive/2023/texmf-dist/tex/latex/hyperref/puenc.def
File: puenc.def 2023-02-07 v7.00v Hyperref: PDF Unicode definition (HO)
Now handling font encoding PU ...
... no UTF-8 mapping file for font encoding PU
)
Package hyperref Info: Option `colorlinks' set `true' on input line 4060.
Package hyperref Info: Hyper figures OFF on input line 4177.
Package hyperref Info: Link nesting OFF on input line 4182.
Package hyperref Info: Hyper index ON on input line 4185.
Package hyperref Info: Plain pages OFF on input line 4192.
Package hyperref Info: Backreferencing OFF on input line 4197.
Package hyperref Info: Implicit mode ON; LaTeX internals redefined.
Package hyperref Info: Bookmarks ON on input line 4425.
\c@Hy@tempcnt=\count275
(/opt/texlive/2023/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip16
Package: url 2013/09/16 ver 3.4 Verb mode for urls, etc.
)
LaTeX Info: Redefining \url on input line 4763.
\XeTeXLinkMargin=\dimen150
(/opt/texlive/2023/texmf-dist/tex/generic/bitset/bitset.sty
Package: bitset 2019/12/09 v1.3 Handle bit-vector datatype (HO)
(/opt/texlive/2023/texmf-dist/tex/generic/bigintcalc/bigintcalc.sty
Package: bigintcalc 2019/12/15 v1.5 Expandable calculations on big integers (HO
)
))
\Fld@menulength=\count276
\Field@Width=\dimen151
\Fld@charsize=\dimen152
Package hyperref Info: Hyper figures OFF on input line 6042.
Package hyperref Info: Link nesting OFF on input line 6047.
Package hyperref Info: Hyper index ON on input line 6050.
Package hyperref Info: backreferencing OFF on input line 6057.
Package hyperref Info: Link coloring ON on input line 6060.
Package hyperref Info: Link coloring with OCG OFF on input line 6067.
Package hyperref Info: PDF/A mode OFF on input line 6072.
(/opt/texlive/2023/texmf-dist/tex/latex/base/atbegshi-ltx.sty
Package: atbegshi-ltx 2021/01/10 v1.0c Emulation of the original atbegshi
package with kernel methods
)
\Hy@abspage=\count277
\c@Item=\count278
\c@Hfootnote=\count279
)
Package hyperref Info: Driver (autodetected): hpdftex.
(/opt/texlive/2023/texmf-dist/tex/latex/hyperref/hpdftex.def
File: hpdftex.def 2023-02-07 v7.00v Hyperref driver for pdfTeX
(/opt/texlive/2023/texmf-dist/tex/latex/base/atveryend-ltx.sty
Package: atveryend-ltx 2020/08/19 v1.0a Emulation of the original atveryend pac
kage
with kernel methods
)
\Fld@listcount=\count280
\c@bookmark@seq@number=\count281
(/opt/texlive/2023/texmf-dist/tex/latex/rerunfilecheck/rerunfilecheck.sty
Package: rerunfilecheck 2022-07-10 v1.10 Rerun checks for auxiliary files (HO)
(/opt/texlive/2023/texmf-dist/tex/generic/uniquecounter/uniquecounter.sty
Package: uniquecounter 2019/12/15 v1.4 Provide unlimited unique counter (HO)
)
Package uniquecounter Info: New unique counter `rerunfilecheck' on input line 2
85.
)
\Hy@SectionHShift=\skip64
)
(/opt/texlive/2023/texmf-dist/tex/latex/booktabs/booktabs.sty
Package: booktabs 2020/01/12 v1.61803398 Publication quality tables
\heavyrulewidth=\dimen153
\lightrulewidth=\dimen154
\cmidrulewidth=\dimen155
\belowrulesep=\dimen156
\belowbottomsep=\dimen157
\aboverulesep=\dimen158
\abovetopsep=\dimen159
\cmidrulesep=\dimen160
\cmidrulekern=\dimen161
\defaultaddspace=\dimen162
\@cmidla=\count282
\@cmidlb=\count283
\@aboverulesep=\dimen163
\@belowrulesep=\dimen164
\@thisruleclass=\count284
\@lastruleclass=\count285
\@thisrulewidth=\dimen165
)
(/opt/texlive/2023/texmf-dist/tex/latex/amsfonts/amsfonts.sty
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\@emptytoks=\toks23
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info: Redeclaring math symbol \hbar on input line 98.
LaTeX Font Info: Overwriting math alphabet `\mathfrak' in version `bold'
(Font) U/euf/m/n --> U/euf/b/n on input line 106.
)
(/opt/texlive/2023/texmf-dist/tex/latex/units/nicefrac.sty
Package: nicefrac 1998/08/04 v0.9b Nice fractions
\L@UnitsRaiseDisplaystyle=\skip65
\L@UnitsRaiseTextstyle=\skip66
\L@UnitsRaiseScriptstyle=\skip67
)
(/opt/texlive/2023/texmf-dist/tex/latex/microtype/microtype.sty
Package: microtype 2023/03/13 v3.1a Micro-typographical refinements (RS)
(/opt/texlive/2023/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count286
)
\MT@toks=\toks24
\MT@tempbox=\box53
\MT@count=\count287
LaTeX Info: Redefining \noprotrusionifhmode on input line 1059.
LaTeX Info: Redefining \leftprotrusion on input line 1060.
\MT@prot@toks=\toks25
LaTeX Info: Redefining \rightprotrusion on input line 1078.
LaTeX Info: Redefining \textls on input line 1368.
\MT@outer@kern=\dimen166
LaTeX Info: Redefining \textmicrotypecontext on input line 1988.
\MT@listname@count=\count288
(/opt/texlive/2023/texmf-dist/tex/latex/microtype/microtype-pdftex.def
File: microtype-pdftex.def 2023/03/13 v3.1a Definitions specific to pdftex (RS)
LaTeX Info: Redefining \lsstyle on input line 902.
LaTeX Info: Redefining \lslig on input line 902.
\MT@outer@space=\skip68
)
Package microtype Info: Loading configuration file microtype.cfg.
(/opt/texlive/2023/texmf-dist/tex/latex/microtype/microtype.cfg
File: microtype.cfg 2023/03/13 v3.1a microtype main configuration file (RS)
))
(/opt/texlive/2023/texmf-dist/tex/latex/lipsum/lipsum.sty
(/opt/texlive/2023/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty
(/opt/texlive/2023/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2023-03-30 L3 programming layer (loader)
(/opt/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
File: l3backend-pdftex.def 2023-03-30 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count289
\l__pdf_internal_box=\box54
))
Package: l3keys2e 2023-02-02 LaTeX2e option processing using LaTeX3 keys
)
Package: lipsum 2021-09-20 v2.7 150 paragraphs of Lorem Ipsum dummy text
\g__lipsum_par_int=\count290
\l__lipsum_a_int=\count291
\l__lipsum_b_int=\count292
(/opt/texlive/2023/texmf-dist/tex/latex/lipsum/lipsum.ltd.tex))
(/opt/texlive/2023/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2021/09/16 v1.2d Enhanced LaTeX Graphics (DPC,SPQR)
(/opt/texlive/2023/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2022/03/10 v1.4e Standard LaTeX Graphics (DPC,SPQR)
(/opt/texlive/2023/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2021/08/11 v1.11 sin cos tan (DPC)
)
(/opt/texlive/2023/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 107.
(/opt/texlive/2023/texmf-dist/tex/latex/graphics-def/pdftex.def
File: pdftex.def 2022/09/22 v1.2b Graphics/color driver for pdftex
))
\Gin@req@height=\dimen167
\Gin@req@width=\dimen168
)
(/opt/texlive/2023/texmf-dist/tex/latex/natbib/natbib.sty
Package: natbib 2010/09/13 8.31b (PWD, AO)
\bibhang=\skip69
\bibsep=\skip70
LaTeX Info: Redefining \cite on input line 694.
\c@NAT@ctr=\count293
)
(/opt/texlive/2023/texmf-dist/tex/latex/doi/doi.sty
Package: doi 2018/09/09 handle doi numbers
)
(/opt/texlive/2023/texmf-dist/tex/latex/tools/array.sty
Package: array 2022/09/04 v2.5g Tabular extension package (FMi)
\col@sep=\dimen169
\ar@mcellbox=\box55
\extrarowheight=\dimen170
\NC@list=\toks26
\extratabsurround=\skip71
\backup@length=\skip72
\ar@cellbox=\box56
)
(/opt/texlive/2023/texmf-dist/tex/latex/listings/listings.sty
\lst@mode=\count294
\lst@gtempboxa=\box57
\lst@token=\toks27
\lst@length=\count295
\lst@currlwidth=\dimen171
\lst@column=\count296
\lst@pos=\count297
\lst@lostspace=\dimen172
\lst@width=\dimen173
\lst@newlines=\count298
\lst@lineno=\count299
\lst@maxwidth=\dimen174
(/opt/texlive/2023/texmf-dist/tex/latex/listings/lstmisc.sty
File: lstmisc.sty 2023/02/27 1.9 (Carsten Heinz)
\c@lstnumber=\count300
\lst@skipnumbers=\count301
\lst@framebox=\box58
)
(/opt/texlive/2023/texmf-dist/tex/latex/listings/listings.cfg
File: listings.cfg 2023/02/27 1.9 listings configuration
))
Package: listings 2023/02/27 1.9 (Carsten Heinz)
(/opt/texlive/2023/texmf-dist/tex/latex/xcolor/xcolor.sty
Package: xcolor 2022/06/12 v2.14 LaTeX color extensions (UK)
(/opt/texlive/2023/texmf-dist/tex/latex/graphics-cfg/color.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package xcolor Info: Driver file: pdftex.def on input line 227.
(/opt/texlive/2023/texmf-dist/tex/latex/graphics/mathcolor.ltx)
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1353.
Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1357.
Package xcolor Info: Model `RGB' extended on input line 1369.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1371.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1372.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1373.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1374.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1375.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1376.
)
(./CT2109-Notes.aux)
\openout1 = `CT2109-Notes.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 84.
LaTeX Font Info: ... okay on input line 84.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 84.
LaTeX Font Info: ... okay on input line 84.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 84.
LaTeX Font Info: ... okay on input line 84.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 84.
LaTeX Font Info: ... okay on input line 84.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 84.
LaTeX Font Info: ... okay on input line 84.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 84.
LaTeX Font Info: ... okay on input line 84.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 84.
LaTeX Font Info: ... okay on input line 84.
LaTeX Font Info: Checking defaults for PD1/pdf/m/n on input line 84.
LaTeX Font Info: ... okay on input line 84.
LaTeX Font Info: Checking defaults for PU/pdf/m/n on input line 84.
LaTeX Font Info: ... okay on input line 84.
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
*geometry* verbose mode - [ preamble ] result:
* driver: pdftex
* paper: letterpaper
* layout: <same size as paper>
* layoutoffset:(h,v)=(0.0pt,0.0pt)
* modes:
* h-part:(L,W,R)=(92.14519pt, 430.00462pt, 92.14519pt)
* v-part:(T,H,B)=(95.39737pt, 556.47656pt, 143.09605pt)
* \paperwidth=614.295pt
* \paperheight=794.96999pt
* \textwidth=430.00462pt
* \textheight=556.47656pt
* \oddsidemargin=19.8752pt
* \evensidemargin=19.8752pt
* \topmargin=-13.87262pt
* \headheight=12.0pt
* \headsep=25.0pt
* \topskip=11.0pt
* \footskip=30.0pt
* \marginparwidth=59.0pt
* \marginparsep=10.0pt
* \columnsep=10.0pt
* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
* \hoffset=0.0pt
* \voffset=0.0pt
* \mag=1000
* \@twocolumnfalse
* \@twosidefalse
* \@mparswitchfalse
* \@reversemarginfalse
* (1in=72.27pt=25.4mm, 1cm=28.453pt)
*geometry* verbose mode - [ newgeometry ] result:
* driver: pdftex
* paper: letterpaper
* layout: <same size as paper>
* layoutoffset:(h,v)=(0.0pt,0.0pt)
* modes:
* h-part:(L,W,R)=(72.27pt, 469.75499pt, 72.27pt)
* v-part:(T,H,B)=(72.26999pt, 650.43pt, 72.27pt)
* \paperwidth=614.295pt
* \paperheight=794.96999pt
* \textwidth=469.75499pt
* \textheight=650.43pt
* \oddsidemargin=0.00002pt
* \evensidemargin=0.00002pt
* \topmargin=-39.0pt
* \headheight=14.0pt
* \headsep=25.0pt
* \topskip=11.0pt
* \footskip=30.0pt
* \marginparwidth=59.0pt
* \marginparsep=10.0pt
* \columnsep=10.0pt
* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
* \hoffset=0.0pt
* \voffset=0.0pt
* \mag=1000
* \@twocolumnfalse
* \@twosidefalse
* \@mparswitchfalse
* \@reversemarginfalse
* (1in=72.27pt=25.4mm, 1cm=28.453pt)
Package hyperref Info: Link coloring ON on input line 84.
(./CT2109-Notes.out) (./CT2109-Notes.out)
\@outlinefile=\write3
\openout3 = `CT2109-Notes.out'.
LaTeX Info: Redefining \microtypecontext on input line 84.
Package microtype Info: Applying patch `item' on input line 84.
Package microtype Info: Applying patch `toc' on input line 84.
Package microtype Info: Applying patch `eqnum' on input line 84.
Package microtype Info: Applying patch `footnote' on input line 84.
Package microtype Info: Applying patch `verbatim' on input line 84.
Package microtype Info: Generating PDF output.
Package microtype Info: Character protrusion enabled (level 2).
Package microtype Info: Using default protrusion set `alltext'.
Package microtype Info: Automatic font expansion enabled (level 2),
(microtype) stretch: 20, shrink: 20, step: 1, non-selected.
Package microtype Info: Using default expansion set `alltext-nott'.
LaTeX Info: Redefining \showhyphens on input line 84.
Package microtype Info: No adjustment of tracking.
Package microtype Info: No adjustment of interword spacing.
Package microtype Info: No adjustment of character kerning.
(/opt/texlive/2023/texmf-dist/tex/latex/microtype/mt-ptm.cfg
File: mt-ptm.cfg 2006/04/20 v1.7 microtype config. file: Times (RS)
)
(/opt/texlive/2023/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count302
\scratchdimen=\dimen175
\scratchbox=\box59
\nofMPsegments=\count303
\nofMParguments=\count304
\everyMPshowfont=\toks28
\MPscratchCnt=\count305
\MPscratchDim=\dimen176
\MPnumerator=\count306
\makeMPintoPDFobject=\count307
\everyMPtoPDFconversion=\toks29
) (/opt/texlive/2023/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
85.
(/opt/texlive/2023/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg
File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv
e
))
\c@lstlisting=\count308
(/opt/texlive/2023/texmf-dist/tex/latex/microtype/mt-cmr.cfg
File: mt-cmr.cfg 2013/05/19 v2.2 microtype config. file: Computer Modern Roman
(RS)
)
LaTeX Font Info: Trying to load font information for U+msa on input line 86.
(/opt/texlive/2023/texmf-dist/tex/latex/amsfonts/umsa.fd
File: umsa.fd 2013/01/14 v3.01 AMS symbols A
)
(/opt/texlive/2023/texmf-dist/tex/latex/microtype/mt-msa.cfg
File: mt-msa.cfg 2006/02/04 v1.1 microtype config. file: AMS symbols (a) (RS)
)
LaTeX Font Info: Trying to load font information for U+msb on input line 86.
(/opt/texlive/2023/texmf-dist/tex/latex/amsfonts/umsb.fd
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
)
(/opt/texlive/2023/texmf-dist/tex/latex/microtype/mt-msb.cfg
File: mt-msb.cfg 2005/06/01 v1.0 microtype config. file: AMS symbols (b) (RS)
) [1
{/opt/texlive/2023/texmf-var/fonts/map/pdftex/updmap/pdftex.map}{/opt/texlive/2
023/texmf-dist/fonts/enc/dvips/base/8r.enc}] (./CT2109-Notes.toc)
\tf@toc=\write4
\openout4 = `CT2109-Notes.toc'.
pdfTeX warning (ext4): destination with the same identifier (name{page.1}) has
been already used, duplicate ignored
<to be read again>
\relax
l.92 \newpage
[1]
<./images//adt.png, id=150, 241.90375pt x 217.81375pt>
File: ./images//adt.png Graphic file (type png)
<use ./images//adt.png>
Package pdftex.def Info: ./images//adt.png used on input line 101.
(pdftex.def) Requested size: 140.92792pt x 126.89705pt.
LaTeX Font Info: Trying to load font information for T1+cmtt on input line 1
18.
(/opt/texlive/2023/texmf-dist/tex/latex/base/t1cmtt.fd
File: t1cmtt.fd 2022/07/10 v2.5l Standard LaTeX font definitions
)
Package microtype Info: Loading generic protrusion settings for font family
(microtype) `cmtt' (encoding: T1).
(microtype) For optimal results, create family-specific settings.
(microtype) See the microtype manual for details.
LaTeX Font Info: Trying to load font information for TS1+ptm on input line 1
20.
(/opt/texlive/2023/texmf-dist/tex/latex/psnfss/ts1ptm.fd
File: ts1ptm.fd 2001/06/04 font definitions for TS1/ptm.
)
(/opt/texlive/2023/texmf-dist/tex/latex/listings/lstlang1.sty
File: lstlang1.sty 2023/02/27 1.9 listings language file
) [2{/opt/texlive/2023/texmf-dist/fonts/enc/dvips/cm-super/cm-super-t1.enc} <./
images//adt.png>]
<./images//ll.png, id=169, 351.3125pt x 64.24pt>
File: ./images//ll.png Graphic file (type png)
<use ./images//ll.png>
Package pdftex.def Info: ./images//ll.png used on input line 171.
(pdftex.def) Requested size: 281.85585pt x 51.54301pt.
<./images//node.png, id=170, 247.92625pt x 97.36375pt>
File: ./images//node.png Graphic file (type png)
<use ./images//node.png>
Package pdftex.def Info: ./images//node.png used on input line 192.
(pdftex.def) Requested size: 140.92792pt x 55.34488pt.
[3 <./images//ll.png> <./images//node.png>] [4] [5]
<./images//comparisonoffunctions1.png, id=244, 1014.79124pt x 577.15625pt>
File: ./images//comparisonoffunctions1.png Graphic file (type png)
<use ./images//comparisonoffunctions1.png>
Package pdftex.def Info: ./images//comparisonoffunctions1.png used on input li
ne 359.
(pdftex.def) Requested size: 375.80542pt x 213.7382pt.
<./images//comparisonoffunctions2.png, id=245, 970.62625pt x 686.565pt>
File: ./images//comparisonoffunctions2.png Graphic file (type png)
<use ./images//comparisonoffunctions2.png>
Package pdftex.def Info: ./images//comparisonoffunctions2.png used on input li
ne 363.
(pdftex.def) Requested size: 375.80542pt x 265.82118pt.
[6 <./images//comparisonoffunctions1.png>] [7 <./images//comparisonoffunctions
2.png>] [8]
<./images//pvsnp.png, id=268, 872.25874pt x 601.24625pt>
File: ./images//pvsnp.png Graphic file (type png)
<use ./images//pvsnp.png>
Package pdftex.def Info: ./images//pvsnp.png used on input line 524.
(pdftex.def) Requested size: 281.85585pt x 194.28345pt.
Underfull \vbox (badness 10000) has occurred while \output is active []
[9]
Package hyperref Info: bookmark level for unknown algorithm defaults to 0 on in
put line 563.
[10 <./images//pvsnp.png>] [11] [12]
<./images//binarytrees.png, id=302, 867.24pt x 393.47pt>
File: ./images//binarytrees.png Graphic file (type png)
<use ./images//binarytrees.png>
Package pdftex.def Info: ./images//binarytrees.png used on input line 690.
(pdftex.def) Requested size: 328.82706pt x 149.18993pt.
[13 <./images//binarytrees.png>]
No file CT2109-Notes.bbl.
[14] (./CT2109-Notes.aux)
Package rerunfilecheck Warning: File `CT2109-Notes.out' has changed.
(rerunfilecheck) Rerun to get outlines right
(rerunfilecheck) or use package `bookmark'.
Package rerunfilecheck Info: Checksums for `CT2109-Notes.out':
(rerunfilecheck) Before: C4445CAE8D3A7CA058755A04227E682D;4176
(rerunfilecheck) After: 213F3292C9B0F0D216A3C578F3C2DCCE;4442.
)
Here is how much of TeX's memory you used:
15981 strings out of 476017
251125 string characters out of 5792769
2074666 words of memory out of 5000000
35747 multiletter control sequences out of 15000+600000
577296 words of font info for 260 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
75i,13n,77p,1005b,1985s stack positions out of 10000i,1000n,20000p,200000b,200000s
</opt/texlive/2023/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></opt
/texlive/2023/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi8.pfb></opt/texlive
/2023/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></opt/texlive/2023/te
xmf-dist/fonts/type1/public/amsfonts/cm/cmr8.pfb></opt/texlive/2023/texmf-dist/
fonts/type1/public/amsfonts/cm/cmsy10.pfb></opt/texlive/2023/texmf-dist/fonts/t
ype1/public/cm-super/sftt0900.pfb></opt/texlive/2023/texmf-dist/fonts/type1/pub
lic/cm-super/sftt1095.pfb></opt/texlive/2023/texmf-dist/fonts/type1/urw/times/u
tmb8a.pfb></opt/texlive/2023/texmf-dist/fonts/type1/urw/times/utmr8a.pfb></opt/
texlive/2023/texmf-dist/fonts/type1/urw/times/utmri8a.pfb>
Output written on CT2109-Notes.pdf (15 pages, 1083233 bytes).
PDF statistics:
413 PDF objects out of 1000 (max. 8388607)
358 compressed objects within 4 object streams
148 named destinations out of 1000 (max. 500000)
60156 words of extra memory for PDF output out of 61914 (max. 10000000)

View File

@ -0,0 +1,29 @@
\BOOKMARK [1][-]{section.1}{\376\377\000A\000b\000s\000t\000r\000a\000c\000t\000\040\000D\000a\000t\000a\000\040\000T\000y\000p\000e\000s}{}% 1
\BOOKMARK [2][-]{subsection.1.1}{\376\377\000S\000t\000a\000c\000k\000s\000\040\000\046\000\040\000Q\000u\000e\000u\000e\000s}{section.1}% 2
\BOOKMARK [3][-]{subsubsection.1.1.1}{\376\377\000S\000t\000a\000c\000k\000s}{subsection.1.1}% 3
\BOOKMARK [3][-]{subsubsection.1.1.2}{\376\377\000Q\000u\000e\000u\000e\000s}{subsection.1.1}% 4
\BOOKMARK [2][-]{subsection.1.2}{\376\377\000L\000i\000n\000k\000e\000d\000\040\000L\000i\000s\000t\000s}{section.1}% 5
\BOOKMARK [3][-]{subsubsection.1.2.1}{\376\377\000I\000m\000p\000l\000e\000m\000e\000n\000t\000a\000t\000i\000o\000n\000\040\000o\000f\000\040\000L\000i\000n\000k\000e\000d\000\040\000L\000i\000s\000t\000s}{subsection.1.2}% 6
\BOOKMARK [3][-]{subsubsection.1.2.2}{\376\377\000S\000i\000n\000g\000l\000y\000\040\000L\000i\000n\000k\000e\000d\000\040\000L\000i\000s\000t\000\040\000C\000l\000a\000s\000s}{subsection.1.2}% 7
\BOOKMARK [1][-]{section.2}{\376\377\000A\000l\000g\000o\000r\000i\000t\000h\000m\000\040\000A\000n\000a\000l\000y\000s\000i\000s}{}% 8
\BOOKMARK [2][-]{subsection.2.1}{\376\377\000A\000l\000g\000o\000r\000i\000t\000h\000m\000\040\000A\000n\000a\000l\000y\000s\000i\000s\000\040\000B\000a\000s\000i\000c\000s}{section.2}% 9
\BOOKMARK [3][-]{subsubsection.2.1.1}{\376\377\000C\000o\000u\000n\000t\000i\000n\000g\000\040\000P\000r\000i\000m\000i\000t\000i\000v\000e\000\040\000O\000p\000e\000r\000a\000t\000i\000o\000n\000s}{subsection.2.1}% 10
\BOOKMARK [2][-]{subsection.2.2}{\376\377\000O\000\040\000N\000o\000t\000a\000t\000i\000o\000n}{section.2}% 11
\BOOKMARK [3][-]{subsubsection.2.2.1}{\376\377\000I\000m\000p\000o\000r\000t\000a\000n\000t\000\040\000F\000u\000n\000c\000t\000i\000o\000n\000s\000\040\000U\000s\000e\000d\000\040\000i\000n\000\040\000O\000\040\000N\000o\000t\000a\000t\000i\000o\000n}{subsection.2.2}% 12
\BOOKMARK [3][-]{subsubsection.2.2.2}{\376\377\000E\000f\000f\000i\000c\000i\000e\000n\000c\000y\000\040\000\046\000\040\000O\000\040\000N\000o\000t\000a\000t\000i\000o\000n}{subsection.2.2}% 13
\BOOKMARK [2][-]{subsection.2.3}{\376\377\000R\000e\000c\000u\000r\000s\000i\000o\000n\000\040\000R\000e\000v\000i\000e\000w}{section.2}% 14
\BOOKMARK [1][-]{section.3}{\376\377\000D\000y\000n\000a\000m\000i\000c\000\040\000P\000r\000o\000g\000r\000a\000m\000m\000i\000n\000g}{}% 15
\BOOKMARK [2][-]{subsection.3.1}{\376\377\000M\000o\000r\000e\000\040\000B\000i\000g\000\040\000G\000r\000e\000e\000k\000\040\000L\000e\000t\000t\000e\000r\000s}{section.3}% 16
\BOOKMARK [2][-]{subsection.3.2}{\376\377\000P\000,\000\040\000N\000P\000,\000\040\000\046\000\040\000N\000P\000-\000C\000o\000m\000p\000l\000e\000t\000e\000\040\000P\000r\000o\000b\000l\000e\000m\000s}{section.3}% 17
\BOOKMARK [1][-]{section.4}{\376\377\000S\000e\000a\000r\000c\000h\000i\000n\000g\000\040\000\046\000\040\000S\000o\000r\000t\000i\000n\000g}{}% 18
\BOOKMARK [2][-]{subsection.4.1}{\376\377\000K\000e\000y\000s\000\040\000\046\000\040\000V\000a\000l\000u\000e\000s}{section.4}% 19
\BOOKMARK [2][-]{subsection.4.2}{\376\377\000J\000a\000v\000a\000\040\000I\000n\000t\000e\000r\000f\000a\000c\000e\000:\000\040\000C\000o\000m\000p\000a\000r\000a\000t\000o\000r}{section.4}% 20
\BOOKMARK [2][-]{subsection.4.3}{\376\377\000J\000a\000v\000a\000\040\000I\000n\000t\000e\000r\000f\000a\000c\000e\000:\000\040\000C\000o\000m\000p\000a\000r\000a\000b\000l\000e}{section.4}% 21
\BOOKMARK [2][-]{subsection.4.4}{\376\377\000I\000n\000s\000e\000r\000t\000i\000o\000n\000\040\000S\000o\000r\000t}{section.4}% 22
\BOOKMARK [2][-]{subsection.4.5}{\376\377\000S\000h\000e\000l\000l\000\040\000S\000o\000r\000t}{section.4}% 23
\BOOKMARK [2][-]{subsection.4.6}{\376\377\000Q\000u\000i\000c\000k\000\040\000S\000o\000r\000t}{section.4}% 24
\BOOKMARK [1][-]{section.5}{\376\377\000T\000r\000e\000e\000s}{}% 25
\BOOKMARK [2][-]{subsection.5.1}{\376\377\000B\000i\000n\000a\000r\000y\000\040\000T\000r\000e\000e\000s}{section.5}% 26
\BOOKMARK [2][-]{subsection.5.2}{\376\377\000G\000e\000n\000e\000r\000i\000c\000s\000\040\000i\000n\000\040\000J\000a\000v\000a}{section.5}% 27
\BOOKMARK [1][-]{section.6}{\376\377\000S\000e\000a\000r\000c\000h\000\040\000T\000r\000e\000e\000s}{}% 28
\BOOKMARK [2][-]{subsection.6.1}{\376\377\000B\000i\000n\000a\000r\000y\000\040\000S\000e\000a\000r\000c\000h\000\040\000T\000r\000e\000e\000s}{section.6}% 29

Binary file not shown.

View File

@ -0,0 +1,745 @@
\documentclass[11pt]{article}
\usepackage{report}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc} % use 8-bit T1 fonts
\usepackage[colorlinks=true, linkcolor=black, citecolor=blue, urlcolor=blue]{hyperref} % hyperlinks
\usepackage{url} % simple URL typesetting
\usepackage{booktabs} % professional-quality tables
\usepackage{amsfonts} % blackboard math symbols
\usepackage{nicefrac} % compact symbols for 1/2, etc.
\usepackage{microtype} % microtypography
\usepackage{lipsum} % Can be removed after putting your text content
\usepackage{graphicx}
\graphicspath{ {./images/} }
\usepackage{natbib}
\usepackage{doi}
\setcitestyle{aysep={,}}
\usepackage{array}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codeorange}{rgb}{1,0.49,0}
\definecolor{backcolour}{rgb}{0.95,0.95,0.96}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegray},
keywordstyle=\color{codeorange},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codegreen},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
xleftmargin=10pt,
}
\lstset{style=mystyle}
\title{CT2109 - Object Oriented Programming: Data Structures \& Algorithms}
\author{Andrew Hayes\\
\AND
\AND
\AND
\AND
\AND
2BCT\\
\AND
University of Galway\\
}
% Uncomment to remove the date
% \date{February 2022}
% Uncomment to override the `A preprint' in the header
\renewcommand{\headeright}{Object Oriented Programming: Data Structures \& Algorithms}
\renewcommand{\undertitle}{Object Oriented Programming: Data Structures \& Algorithms}
\renewcommand{\shorttitle}{}
%%% Add PDF metadata to help others organize their library
%%% Once the PDF is generated, you can check the metadata with
%%% $ pdfinfo template.pdf
% \hypersetup{
% pdftitle={A template for the arxiv style},
% pdfsubject={q-bio.NC, q-bio.QM},
% pdfauthor={David S.~Hippocampus, Elias D.~Striatum},
% pdfkeywords={First keyword, Second keyword, More},
% }
\begin{document}
\maketitle
\newpage
\tableofcontents
\thispagestyle{empty}
\setcounter{page}{1}
\newpage
\section{Abstract Data Types}
An \textbf{Abstract Data Type (ADT)} is an abstract model of a data structure that specifies the data stored \& oeprations that may be performed on the data.
An ADT specifies \textit{what} each operation does, but not \textit{how}.
In object-oriented languages such as Java, this naturally corresponds to an \textbf{interface definition}.
An ADT is \textit{realised} as a concrete data structure.
In Java, this is a class that \textbf{implements} the interface.
\begin{center}
\includegraphics[width=0.3\textwidth]{adt.png}
\end{center}
\textbf{Composite ADTs} are used manage \textit{collections} of data, e.g., Arrays, Lists, Stacks, Queues, Hash Tables, etc.
\subsection{Stacks \& Queues}
\textbf{Stacks} \& \textbf{Queues} are linearly ordered ADTs for list-structured data.
\subsubsection{Stacks}
A \textbf{Stack} is a last in, first out (LIFO) data structure.
No sort order is assumed.
Items can only enter or leave via the \textit{top} of the stack.
Items can be \textbf{pushed} \& \textbf{popped} to add \& remove.
Example applications of a stack include processing nested structures or the ``undo'' operation in an editor.
Objects stored in a stack are a \textit{finite sequence} of elements of the \textbf{same type}.
Stacks have few operations.
For a stack \verb|s|, node \verb|n|, \& boolean value \verb|b|:
\begin{itemize}
\item \verb|s.push(n)| - Place item \verb|n| on top of the stack.
\item \verb|s.pop()| $\rightarrow$ \verb|n| - Remove top item from the stack \& return it.
\item \verb|s.top| $\rightarrow$ \verb|n| - Examine the top item on the stack without removing it.
\item \verb|s.isEmpty()| $\rightarrow$ \verb|b| - Returns \verb|b = true| if the stack is empty.
\item \verb|s.isFull()| $\rightarrow$ \verb|b = true| if the stack is full (relevant if storage is limited).
\end{itemize}
Java has a built-in stack interface from \verb|java.util.Stack|.
However, we will look at making our own for the sake of learning.
Our stack implementation may look something like this:
\begin{lstlisting}[language=java]
public interface Stack {
public void push(Object n);
public Oject pop();
public Object top();
public boolean isEmpty();
public boolean isFull();
\end{lstlisting}
Other stack operations include \verb|size()| \& \verb|makeEmpty()|.
We could implement this stack using an array, linked list, or other storage type.
\subsubsection{Queues}
A \textbf{Queue} is a first in, first out (FIFO) data structure.
No sort order is assumed.
Items enter at the rear of the queue, and leave at the front of the queue.
Items can be \textbf{enqueued} \& \textbf{dequeued} to add \& remove them from the queue.
Example applications of a queue include ensuring ``fair treatment'' to each of a list of pending tasks (first come, first served)
or simulation: modelling \& analysis of real-world problems.
Objects stored in a queue are a finite sequence of elements of the same type.
The item at the front of the queue has been in the queue the longest, while the item at the rear has entered the queue most recently.
Queues have few operations.
For a queue \verb|q|, element \verb|e|, \& boolean value \verb|b|:
\begin{itemize}
\item \verb|q.enqueue(e)| - Place \verb|e| at the rear of \verb|q|, assuming there is space.
\item \verb|q.dequeue()| $\rightarrow$ \verb|e| - Remove fron item \verb|e| from \verb|q| and return it.
\item \verb|q.front()| $\rightarrow$ \verb|e| - Returns front element \verb|e| without removing it.
\item \verb|q.isEmpty()| $\rightarrow$ \verb|b| - Returns \verb|b = true| if the queue is empty.
\item \verb|q.isFull()| $\rightarrow$ \verb|b| - Returns \verb|b = true| if the queue is full.
\end{itemize}
With an array implementation of a queue, items must be ``shuffled'' towards the front after a \textit{dequeue}.
Note that with an array implementation, once \verb|rear| becomes equal to $N-1$, no further items can be enqueued (array space limitation).
\subsection{Linked Lists}
A \textbf{Linked List} is an abstract data type which stores an arbitrary-length list of data objects as a sequence of \textit{nodes}.
Each node consists of data and has a \textbf{link} to the next node.
Each node, excepting the last, is links to a \textbf{successor node}.
\begin{center}
\includegraphics[width=0.6\textwidth]{ll.png}
\end{center}
Characteristics of Linked Lists:
\begin{itemize}
\item \textbf{Self-referential} structure type - Every node has a pointer to a node of the same type.
\item Very useful for \textbf{dynamically} growing/shrinking lists of data.
\item Compared to arryas, drastically reduces the effort required to add/remove items from the middle of the list.
\item Solves the potential problem of \textbf{overflow} that arrays have.
\item \textbf{Sequential access} - It is \textbf{inefficient} to retrieve an element at an arbitrary position, relative to an array.
\end{itemize}
\subsubsection{Implementation of Linked Lists}
We define a \textbf{Node} class, with members \textbf{data} (whichever variables are required) \& \textbf{next} (reference to another Node object).
Each node occcurrence is linked to a succeeding occurence by way of the member \textbf{next}.
If \verb|next| is \verb|null|, then there is no item after this node in the list (termed the \textbf{tail} node).
The starting point for the list is the \textbf{head} node.
We can trace from the head node to any other node.
\begin{center}
\includegraphics[width=0.3\textwidth]{node.png}
\end{center}
\begin{lstlisting}[language=Java]
public class Node {
// instance variables
private Object element;
private Node next;
// creates node with null refs to its element \& next node
public Node() {
this(null, null);
}
// creates node with the given element & next node
public Node(Object e, Node n) {
element = e;
next = n;
}
// accessor methods
public Object getElement() {
return element;
}
public Node getNext() {
return next;
}
// mutator methods
public void setElement(Object newElem) {
element = newElem;
}
public void setNext(Node newNext) {
next = newNext;
}
}
\end{lstlisting}
Generally, we don't create nodes manually, rather we just supply element data to a method which keeps track of the current position in the list.
Typical methods in a Linked List ADT include:
\begin{itemize}
\item \verb|long size()| - Returns the size of the list.
\item \verb|boolean isEmpty()| - Returns \verb|true| if the list is empty, \verb|false| otherwise.
\item \verb|Object getCurr()| - Returns the element at the current position.
\item \verb|boolean gotoHead()| - Sets the current position to \verb|head|, returning \verb|true| if successful.
\item \verb|boolean gotoNext()| - Moves to the next position, returning \verb|true| if successful.
\item \verb|void insertNext(Object el| - Creates a new node after the current node.
\item \verb|void deleteNext()| - Removes the node after the current node.
\item \verb|void insertHead(Object el)| - Creates a new node at the head.
\item \verb|void deleteHead()| - Removes the head node.
\end{itemize}
\subsubsection{Singly Linked List Class}
A \textbf{singly linked list} is one in which each node links to a \textit{single} other node.
The Singly Linked List Class should store the head of the list \& the current position.
For efficiency, it also keeps track of the current size of the list (alternatively, we could just count its nodes when needed).
\begin{lstlisting}[language=Java]
public class SLinkedList {
protected Node head; // head node of the list
protected Node curr; // current position in list
protected long size; // number of nodes in the list
// default constructor which creates an empty list
public SLinkedList() {
curr = head = null;
size = 0;
}
// insert, remove, & search methods go here
}
\end{lstlisting}
\section{Algorithm Analysis}
All algorithms take CPU \textbf{time} \& \textbf{memory} space.
Often, we can make tradeoffs, choosing algorithm variants that either user more memory, or more CPU.
If the memory space requirements of an algorithm are large, the program may use disk sawp space rather than RAM, which is much slower.
If the memory requirements are too large, then the program cannot run.
Often, we identify the algorithms that don't require ``too much'' spaace, and then choose the one with the lowest
CPU requirements.
The purpose of algorithm analysis is comparing the time \& space requirements of various algorithms.
``Why not just run the algorithm and measure the time \& space used?'' -
While this is sometimes done when theoretical analysis is difficult, it is better to be able to evaluate
algorithms ``on paper'' without first having to implement, debug, and test them all.
It's important to have a measure that's \textit{independent} of particular computer configurations and to be able to
compare algorithms reliably, without being influenced by variations in implementation.
We want to understand how an algorithm will perform on large problems and identify ``hot spots'' to give our attention
to when developing \& optimising programs.
\subsection{Algorithm Analysis Basics}
\textbf{Theoretical Analysis} uses a high-level \textit{pseudocode} description of the algorithm instead of a real
implementation, and characterises run-time as a function of input size $n$.
This function specifies the \textbf{order of growth} of rate of runtime as $n$ increases.
Theoretical analysis takes into account all possible inputs and evaluates speed independent of hardware or software.
\subsubsection{Counting Primitive Operations}
The basic approach is deriving the function for the \textbf{count of the primitive operations}.
The primitive operations are the individual steps performed by a program.
We assume that each step takes the same amount of time and examine any terms that control repetition.
Example: Algorithm to find the largest element of an array.
We count the maximum number of operations as function of array size $n$.
\begin{lstlisting}
Algorithm arrayMax(A, n) // Number of Operations
currentMax = A[0] // 2
for i = 1 to n -1 do // 2n
if A[i] > currentMax then // 2(n-1)
currentMax = A[i] // 2(n-1)
{increment coutner i} // 2(n-1)
return currentMax // 1
// Total: 8n-3
\end{lstlisting}
We could consider the \textbf{average}, \textbf{best}, or \textbf{worst} case.
Usually, we analyse the worst case, as we want our algorithms to work well even in bad cases.
The average case is quite important too, if different from the worst case.
These counts are the basis of (big) O notation.
\subsection{O Notation}
The basic approach to \textbf{O Notation} involves deriving an expression for the count of basic operations (as
discussed).
We focus on the \textit{dominant term}, and ignore constants.
E.g., $O(5n^2 + 1000n -3) \rightarrow O(n^2)$.
Since contants \& low-order terms are eventually dropped, we can disregard them when counting primitive operations.
O Notation is used for \textbf{asymptotic analysis of complexity} - the trend in the algorithms runtime as $n$
gets large.
We look at the \textbf{order of magnitude} of the number of actions, independent of computer/compiler/etc.
Note: We specifically care about the \textbf{tightest} upper bound.
Technically speaking, an algorithm that is $O(n^2)$ is also $O(n^3)$, but the former is more informative.
The function specified in O notation is the \textbf{upper bound} on the behaviour of the algorithm being analysed.
This can be the best/average/worst case behaviour.
Example: Let $f(n) = 6n^4 -2n^3 + 5$.
Apply the following rules:
\begin{itemize}
\item If $f(n)$ is a sum of several terms, then only the one with largest rate of growth is kept.
\item If $f(n)$ is a product of several factors, any constants that do not depend on $n$ are ommitted.
\end{itemize}
Thus, we say that $f(n)$ has a ``big-oh'' of $(n^4)$.
We can write $f(n)$ is $O(n^4)$.
\subsubsection{Important Functions Used in O Notation}
Functions commonly used include:
\begin{itemize}
\item \textbf{Constant:} $O(1)$.
\item \textbf{Logarithmic:} $O($log$n)$.
\item \textbf{Linear:} $O(n)$.
\item \textbf{n-Log-n:} $O(n$log$n)$.
\item \textbf{Quadratic:} $O(n^2)$.
\item \textbf{Cubic:} $O(n^3)$.
\item \textbf{Exponential:} $(1^n)$.
\end{itemize}
Notes:
\begin{itemize}
\item By convention, all logs are base 2 unless otherwise stated.
\item Two algorithms having the same complexity doesn't been that they are exactly the same, it means that their
running times will be \textit{proportional}.
\end{itemize}
\begin{center}
\includegraphics[width=0.8\textwidth]{comparisonoffunctions1.png}
\end{center}
\begin{center}
\includegraphics[width=0.8\textwidth]{comparisonoffunctions2.png}
\end{center}
\subsubsection{Efficiency \& O Notation}
\begin{itemize}
\item \textbf{Constant:} Most efficient possible, but only applicable to simple jobs.
\item \textbf{Logarithmic, Linear, \& n-Log-n:} If an algorithm is described as ``efficient'', this usually means
$O($log$n)$ or better.
\item \textbf{Quadratic \& Cubic:} Not very efficient, but polynomial algorithms are usually considered ``tractable''
(acceptable for problems of reasonable size).
\item \textbf{Exponential:} Very inefficient. Problems that (provably) require an algorithm of O greater than
polynomial complexity are called ``\textbf{hard}''.
\end{itemize}
\subsection{Recursion Review}
Methods can call other methods, but they can also call themselves, either directly, or indirectly, via
another method.
This creates a type of loop called \textbf{recursion}.
Iteration can be used anywhere that you can use recursion.
Sometimes, recursion can be a more elegant solution, if it reflects the way that the problem is usually thought
about, as we aim to use the most intuitive representation of the problem.
Recursion can make complexity analysis easier in some cases.
The drawbacks of recursion include:
\begin{itemize}
\item Inefficient use of the function: Large amount of concurrent, deeply nested method calls.
\item If done naively, the number of calls can explode.
\item Depending on the algorithm, we need to take care not to recompute values unnecessarily.
\end{itemize}
\section{Dynamic Programming}
The basic idea of \textbf{Dynamic Programming} is to solve complex problems by breaking them into simpler
sub-problems.
When a solution to a sub-problem is found, store it (``memo-ize'') so that it can be re-used without
recomputing it.
Combine the solutions to the sub-problems to get the overall solution.
This is particularly useful when the number of repeating sub-problems grows exponentially with the problem
size.
In general, dynamic programming takes problems that appear exponential and produces polynomial-time algorithms
for them.
The trade-off in dynamic programming is between \textit{storage} \& \textit{speed}.
Dynamic programming is widely used in heuristic optimisation problems.
For Dynamic Programming, the problem structure requires three components:
\begin{enumerate}
\item \textbf{Simple sub-problems:} Must be able to break the overall problem into indexed sub-problems
\& sub-sub-problems.
\item \textbf{Sub-problem decomposition:} Optimal/correct solution to the overall problem must be
composed from sub-problems.
\item \textbf{Sub-problem overlap:} So that elements can be re-used.
\end{enumerate}
The basic steps in the approach to DynProg:
\begin{enumerate}
\item Set up the overall problem as one that is decomposable into overlapping sub-problems that can
be indexed.
\item Solve the sub-problems as they arise and \textbf{store solutions} in a table.
\item Derive the overall solution from the solutions in the table.
\end{enumerate}
\subsection{More Big Greek Letters}
$O(n$log$n)$ (``Big Oh''):
\begin{itemize}
\item Upper bound on asymptotic complexity.
\item In this case, there is a constant $c_2$ such that $c_2 n$log$n$ is an upper bound on
asymptotic complexity.
\end{itemize}
$\Omega(n$log$n)$ (``Big Omega''):
\begin{itemize}
\item Specifies a lower bound on asymptotic complexity.
\item In this case, the algorithm has a lower bound of $c_1 n$log$n$.
\end{itemize}
$\Theta(n$log$n)$ (``Big Theta''):
\begin{itemize}
\item Specifies the upper \& lower bounds.
\item In this case, there exist two constants, $c_1$ \& $c_2$, such that $c_1n$log$n < f(n) < c_2n$log$n$.
\end{itemize}
Of these, $\Theta()$ makes the strongest claims: It specifies that the rate of growth is no better and no
worse than some level.
Requires additional analysis relative to $O$.
There are also some others that are common in Mathematics but not in Computer Science:
\begin{itemize}
\item \textbf{Little o:} $o(g(n))$ specifies a function $g(n)$ that grows much faster than the one
that we are analysing.
\item \textbf{Little omega:} $\omega(g(n))$ specifies a function $g(n)$ that grows much slower than
the one that we are analysing.
\end{itemize}
Don't confuse upper/lower bounds with best/worst case: all cases have bounds.
\newpage
\subsection{P, NP, \& NP-Complete Problems}
\textbf{P Problems} are those for which there is a \textbf{deterministic} algorithm that solves it in
\textbf{Polynomial Time}.
In other words, the algorithm's complexity is $O(p(n))$ where $p(n)$ is a polynomial function.
A (trivial) example of a P problem is searching an array of integers for a certain value.
Problems that can be solved in polynomial time are termed \textbf{tractable}, while worse problems are
termed \textbf{intractable}.
\textbf{NP Problems (Non-deterministic Polynomial)} are those algorithms which have two repeating steps:
\begin{itemize}
\item Generate a \textit{potential solution}, either randomly or systematically.
\item Verify whether the potential solution is right, and if not, repeat.
\end{itemize}
If the verification step is \textbf{polynomial}, the algorithm \& associated problem are \textbf{NP}.
An example of an NP problem is factoring large integers as used in RSA encryption.
Another example of an NP problem is the \textbf{subset problem}:
Given a set of integers, does some non-empty subset of them sum to 0?
There is no polynomial algorithm to solve this problem.
However, verification of a potential solution is polynomial ($O(n)$ (just add up the numbers in the
potential solution)).
Note that P is a subset of NP.
\textbf{NP-Complete} problems are those that are ``\textbf{as hard as} all others'' in NP, i.e. algorithms that
are comparable to (``\textbf{polynomially reducible} to'') others in NP but not reducible to P.
If an algorithm is \textbf{polynomially reducible}, there is some polynomial-time transformation that
converts the inputs for Problem $X$ to inputs for Problem $Y$.
NP-Complete is a complexity class which represents the set of all problems $X$ in NP for which it is
possible to reduce any other NP problem $Y$ to $X$ in polynomial time.
Intuitively, this means that we can solve $Y$ quickly if we know how to solve $X$ quickly.
What makes NP-complete problems inportant is that if a deterministic polynomial time algorithm can be
found to solve one of them, every NP problem is solvable in polynomial time.
\textbf{NP-Hard} problems are those that are ``\textbf{as hard or harder}'' than all others in NP.
A problem $X$ is Np-Hard if NP-Complete problems are polynomially reducible to it.
Intuitively, NP-hard problems are problems that are at least as hard as the NP-complete problems.
Note that NP-hard problems do not have to be in NP, and they do not have to be decision problems.
The precise definition here is that ``a problem $X$ is NP-hard, if there is an NP-complete problem $Y$,
such that $Y$ is reducible to $X$ in polynomial time''.
An example of an NP-hard problem is \textit{the halting problem}: Given a program $P$ and input $I$,
will it halt?
The ``P versus NP'' problem is a major unsolved problem in computer science:
``If the solution to a problem is easy to verify, is the problem also easy to solve?'' or ``whether
every problem whose solution can be \textbf{quickly verified} by a computer can also be \textbf{quickly solved}
by a computer''.
``Quickly'' here means that there exists an algorithm to solve the task that runs in polynomial time.
An answer to the $P = NP$ question would determine whether all problems that can be verified in polynomial time can also be solved in
polynomial time.
If it turned out that $P \neq NP$, then it would mean that there are problems in NP (such as NP-complete problems) that are harder to compute
than to verify.
We already know that $P \subseteq NP$.
In theoretical computer science, the problems considered for P \& NP are \textbf{decision problems}, i.e. problems that don't produce
numeric results but yes or no answers.
\begin{center}
\includegraphics[width=0.6\textwidth]{pvsnp.png}
\end{center}
\begin{itemize}
\item \textbf{P} (Polynomial): Solvable in polynomial time.
\item \textbf{NP} (Non-Deterministic Polynomial): Only \textit{verifiable} in polynomial time.
\end{itemize}
\section{Searching \& Sorting}
\subsection{Keys \& Values}
Each object to be sorted can be considered to have a \textbf{key} \& a \textbf{value}, e.g. A Student has properties Name, ID, \& grade.
\subsection{Java Interface: Comparator}
The \verb|Comparator| interface compares two objects to say which should come first.
In Java, any class that implements \verb|java.util.Comparator| interface is only required to implement one method:
\begin{lstlisting}[language=java]
int compare(Object ob1, Object ob2);
\end{lstlisting}
This returns a negative number if \verb|ob1| is less than \verb|ob2|, a positive number if \verb|ob1| is greater than \verb|ob2|, and \verb|0| if \verb|ob1| is equal to \verb|ob2|.
\subsection{Java Interface: Comparable}
The \verb|Comparable| interface compares a given object to another to see which object should come first.
The two objects that are being compared must be of a class that implements \verb|java.lang.Comparable|, which has just one method to implement:
\begin{lstlisting}[language=java]
int compareTo(Object other);
\end{lstlisting}
Standard classes such as \verb|String| implement this.
\subsection{Insertion Sort}
Consider sorting a bookshelf using \textbf{Insertion Sort}:
\begin{enumerate}
\item Remove the next unsorted book.
\item Slide the sorted books to the right one by one until you find the right sport for for the removed book.
\item Insert the book into its new position once it is found.
\end{enumerate}
\begin{algorithm}
\caption{Insertion Sort Pseudocode}
\begin{algorithmic}
\Require{$A[0 \dots N-1]$} \Comment{Unsorted Array}
\Ensure{$A[0 \dots N-1]$} \Comment{Sorted Array}
\Procedure{Insertion Sort}{$A[0 \dots N-1]$}
\For{$ToSort \gets 1$ to $N-1$ Step 1}
\State $Index = ToSort -1$
\State $ToSortEl = A[ToSort]$
\\
\While{$Index \geq First$ AND $A[Index] > ToSortEl$}
\State $A[Index+1] \gets A[Index]$ \Comment{Shuffle elements to the right}
\State $Index \gets Index - 1$
\EndWhile
\\
\State $A[Index+1] = ToSortEl$ \Comment{Insert the element to sort in its appropriate place}
\EndFor
\State \textbf{return} $A[]$ \Comment{Return the sorted array}
\EndProcedure
\end{algorithmic}
\end{algorithm}
The worst case efficiency of Insertion Sort is $O(n^2)$.
The best case efficiency of Insertion Sort is $O(n)$.
If the array is closer to sorted order, the algorithm does less work, and the operation is more efficient.
This leads to a related algorithm: Shell Sort.
\newpage
\subsection{Shell Sort}
\textbf{Shell Sort} is more efficient than Selection Sort or Insertion Sort.
It works by comparing distant items first, and works its way down to nearby items.
The interval is called the \textbf{gap}.
The gap begins at one half of the length of the list and is successively halved until each item has been compared with its neighbour.
Insertion Sort only tests elements in \textit{adjacent} locations - it might take several steps to get to the final location.
Insertion Sort is more efficient if an array is partially sorted.
By making larger jumps, Shell Sort makes the array become ``more sorted'' more quickly.
\begin{algorithm}
\caption{Shell Sort Pseudocode}
\begin{algorithmic}
\Require{$A[0 \dots N-1]$} \Comment{Unsorted Array}
\Ensure{$A[0 \dots N-1]$} \Comment{Sorted Array}
\Procedure{Shell Sort}{$A[0 \dots N-1]$}
\State $Gap \gets floor(\frac{Gap}{2})$ \Comment{Round to the nearest odd number, as it's best with an odd-sized gap}
\\
\While{$Gap \geq 1$}
\For{$ToSort \gets 1$ to $N-1$ Step 1}
\State $Index = ToSort -1$
\State $ToSortEl = A[ToSort]$
\\
\While{$Index \geq First$ AND $A[Index] > ToSortEl$}
\State $A[Index+1] \gets A[Index]$ \Comment{Shuffle elements to the right}
\State $Index \gets Index - 1$
\EndWhile
\\
\State $A[Index+1] = ToSortEl$ \Comment{Insert the element to sort in its appropriate place}
\EndFor
\\
\State $Gap \gets floor(\frac{Gap}{2})$
\EndWhile
\EndProcedure
\end{algorithmic}
\end{algorithm}
The worst-case complexity of Shell Sort is $O(n^2)$.
However, this is because the gap is sometimes even which results in sub-arrays that include all the elements of an array that was already sorted.
To avoid this, we round the gap up to the nearest odd number which gives us a worst-case complexity of $O(n^{1.5})$.
Other gap sequences can improve performance a little more, but this is beyond the scope of this topic.
\subsection{Quick Sort}
\textbf{Quick Sort} is a divide-and-conquer algorithm.
\begin{enumerate}
\item Firstly, it partitions the array into two sub-arrays that are \textbf{partially sorted}.
\item Then, it picks a \textbf{pivot value}, and re-arranges the elements such that all elements less than or equal to the pivot value are on the left of the pivot, and all elements that are greater than
it are on the right.
\item The array is now divided into sub-arrays and a pivot value.
\item This procedure is then repeated \textbf{recursively} for each sub-array, to further sort each of them.
\item When the algorithm has reached the level of a sub-array with just one element, that sub-array is sorted.
All sub-arrays are sorted relative to each other, so the whole array is sorted when all the sub-arrays are.
\end{enumerate}
\section{Trees}
The data structures that we looked at previously placed data in linear order, but we sometimes need to organise data into groups \& sub-groups.
This is called \textbf{hierarchical classification}, where data items appear at various levels within the organisation.
In Computer Science, a tree is an abstract model of a hierarchical structure which consists of nodes with a parent-child relation.
Trees have applications in organisation charts, file systems, programming environments, \& more.
A \textbf{tree} is a set of nodes, connected by edges.
The edges indicate relationships between nodes.
Nodes are arranged in \textbf{levels}, which indicate the node's position in the hierarchy.
Nodes with the same parent node are called \textbf{siblings}.
The only node with no parent is the \textbf{root} node.
All other nodes have one parent each.
A node with no child nodes is called a \textbf{leaf} node or an \textbf{external} node.
All other nodes are referred to as \textbf{internal} nodes.
A node is reached from the root by a \textbf{path}.
The length of a path is the number of edges that compose it.
This is also referred to as the depth of the node.
The \textbf{height} of a tree is the number of levels in the tree.
The number of nodes along the longest path is equal to the maximum depth plus one.
Note that we talk about the depth of a node, but the height of a tree.
The ancestors of a node include its parent, grandparent, great-grandparent, etc.
The descendants of a node include its children, grandchildren, great-grandchildren, etc.
A \textbf{subtree} of a node is a tree that has that node as its root, including the node, all its descendants, and the arcs connecting them.
\subsection{Binary Trees}
A \textbf{binary tree} is one in which each internal node has at most two children (\& exactly two if it is a ``\textbf{proper}'' binary tree).
The children of a node are an \textbf{ordered pair}.
We refer to the children of an internal node as the left child \& the right child.
Non-binary trees are termed general trees.
An alternative (recursive) definition for binary trees is a tree that is either just single node or a tree whose root has an ordered pair of children, each of which is a binary tree.
A \textbf{full binary tree} is one in which is a proper binary tree, and in which all the leaves are on the same level.
This is only achievable for certain numbers of nodes.
A \textbf{complete binary tree} is a binary tree which is full to the penultimate level and the leaves on the last level are filled frmo left to right.
This is achievable for any number of nodes.
The height of either a complete or full binary tree with $n$ nodes is log$_2(n+1)$.
\begin{center}
\includegraphics[width=0.7\textwidth]{binarytrees.png}
\end{center}
\subsection{Generics in Java}
The \verb|< >| operators relate to the concept of \textbf{generics}.
Generics are used to specify a specific type parameter for a generic collection class.
This saves us from having to cast objects in methods such as \verb|add()|, \verb|set|, \& \verb|remove|.
This is a big advantage, as type checking is now done at compile time.
Without generics, compile-time type-checking is impossible, since we don't have a type specification for the list.
Other object-oriented programming languages have similar concepts, such as templates in C++.
\verb|ArrayList|s are part of the Java Collections framework, a standard library of pre-built data structures.
The underlying storage of an \verb|ArrayList| is an array.
The \verb|ArrayList| class looks after resizing it as required.
\verb|ArrayLists| can be used with or without generics notation.
\begin{lstlisting}[language=Java]
// ArrayList code without generics:
ArrayList words = new ArrayList(); // holds objects
words.add("hello");
String a = (String) words.get(0); // return type of get() is object, so must cast to String
// ArrayList parameterised to specifically hold Strings
ArrayList<String> words = new ArrayList<String>();
words.add("hello");
String a = words.get(0); // no cast needed
\end{lstlisting}
Creating a Generics collection:
\begin{lstlisting}[language=Java]
public interface List<E> {
void add(E x);
Iterator<E> iterator();
}
public interface Iterator<E> {
E next();
boolean hasNext();
}
\end{lstlisting}
\section{Search Trees}
A \textbf{Search Tree} organises its data so that searching it is efficient.
\subsection{Binary Search Trees}
A \textbf{Binary Search Tree (BST)} is a binary tree with nodes that contain \verb|Comparable| objects.
A node's data is greater than the data in the left subtree and less than the data in the right subtree.
Usually, no duplicates are allowed.
An \textbf{in-order} traversal of a BST will visit all nodes in ascending order.
BSTs are not uniquely structured - The structure of a BST depends on what node is chosen as the root of the tree and the order in which all the other nodes are added.
\bibliographystyle{unsrtnat}
\bibliography{references}
\end{document}

View File

@ -0,0 +1,29 @@
\contentsline {section}{\numberline {1}Abstract Data Types}{2}{section.1}%
\contentsline {subsection}{\numberline {1.1}Stacks \& Queues}{2}{subsection.1.1}%
\contentsline {subsubsection}{\numberline {1.1.1}Stacks}{2}{subsubsection.1.1.1}%
\contentsline {subsubsection}{\numberline {1.1.2}Queues}{2}{subsubsection.1.1.2}%
\contentsline {subsection}{\numberline {1.2}Linked Lists}{3}{subsection.1.2}%
\contentsline {subsubsection}{\numberline {1.2.1}Implementation of Linked Lists}{3}{subsubsection.1.2.1}%
\contentsline {subsubsection}{\numberline {1.2.2}Singly Linked List Class}{4}{subsubsection.1.2.2}%
\contentsline {section}{\numberline {2}Algorithm Analysis}{5}{section.2}%
\contentsline {subsection}{\numberline {2.1}Algorithm Analysis Basics}{5}{subsection.2.1}%
\contentsline {subsubsection}{\numberline {2.1.1}Counting Primitive Operations}{5}{subsubsection.2.1.1}%
\contentsline {subsection}{\numberline {2.2}O Notation}{5}{subsection.2.2}%
\contentsline {subsubsection}{\numberline {2.2.1}Important Functions Used in O Notation}{6}{subsubsection.2.2.1}%
\contentsline {subsubsection}{\numberline {2.2.2}Efficiency \& O Notation}{7}{subsubsection.2.2.2}%
\contentsline {subsection}{\numberline {2.3}Recursion Review}{7}{subsection.2.3}%
\contentsline {section}{\numberline {3}Dynamic Programming}{7}{section.3}%
\contentsline {subsection}{\numberline {3.1}More Big Greek Letters}{8}{subsection.3.1}%
\contentsline {subsection}{\numberline {3.2}P, NP, \& NP-Complete Problems}{9}{subsection.3.2}%
\contentsline {section}{\numberline {4}Searching \& Sorting}{10}{section.4}%
\contentsline {subsection}{\numberline {4.1}Keys \& Values}{10}{subsection.4.1}%
\contentsline {subsection}{\numberline {4.2}Java Interface: Comparator}{10}{subsection.4.2}%
\contentsline {subsection}{\numberline {4.3}Java Interface: Comparable}{10}{subsection.4.3}%
\contentsline {subsection}{\numberline {4.4}Insertion Sort}{10}{subsection.4.4}%
\contentsline {subsection}{\numberline {4.5}Shell Sort}{12}{subsection.4.5}%
\contentsline {subsection}{\numberline {4.6}Quick Sort}{12}{subsection.4.6}%
\contentsline {section}{\numberline {5}Trees}{13}{section.5}%
\contentsline {subsection}{\numberline {5.1}Binary Trees}{13}{subsection.5.1}%
\contentsline {subsection}{\numberline {5.2}Generics in Java}{13}{subsection.5.2}%
\contentsline {section}{\numberline {6}Search Trees}{14}{section.6}%
\contentsline {subsection}{\numberline {6.1}Binary Search Trees}{14}{subsection.6.1}%

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,264 @@
\NeedsTeXFormat{LaTeX2e}
\ProcessOptions\relax
% fonts
\renewcommand{\rmdefault}{ptm}
\renewcommand{\sfdefault}{phv}
% set page geometry
\usepackage[verbose=true,letterpaper]{geometry}
\AtBeginDocument{
\newgeometry{
textheight=9in,
textwidth=6.5in,
top=1in,
headheight=14pt,
headsep=25pt,
footskip=30pt
}
}
\widowpenalty=10000
\clubpenalty=10000
\flushbottom
\sloppy
\newcommand{\headeright}{Ph.D. Confirmation Report}
\newcommand{\undertitle}{Ph.D. Confirmation Report}
\newcommand{\shorttitle}{\@title}
\usepackage{fancyhdr}
\fancyhf{}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.4pt}
\fancyheadoffset{0pt}
\rhead{\scshape \footnotesize \headeright}
\chead{\shorttitle}
\cfoot{\thepage}
%Handling Keywords
\def\keywordname{{\bfseries \emph{Keywords}}}%
\def\keywords#1{\par\addvspace\medskipamount{\rightskip=0pt plus1cm
\def\and{\ifhmode\unskip\nobreak\fi\ $\cdot$
}\noindent\keywordname\enspace\ignorespaces#1\par}}
% font sizes with reduced leading
\renewcommand{\normalsize}{%
\@setfontsize\normalsize\@xipt\@xiipt
\abovedisplayskip 7\p@ \@plus 2\p@ \@minus 5\p@
\abovedisplayshortskip \z@ \@plus 3\p@
\belowdisplayskip \abovedisplayskip
\belowdisplayshortskip 4\p@ \@plus 3\p@ \@minus 3\p@
}
\normalsize
\renewcommand{\small}{%
\@setfontsize\small\@xpt\@xipt
\abovedisplayskip 6\p@ \@plus 1.5\p@ \@minus 4\p@
\abovedisplayshortskip \z@ \@plus 2\p@
\belowdisplayskip \abovedisplayskip
\belowdisplayshortskip 3\p@ \@plus 2\p@ \@minus 2\p@
}
\renewcommand{\footnotesize}{\@setfontsize\footnotesize\@ixpt\@xpt}
\renewcommand{\scriptsize}{\@setfontsize\scriptsize\@viipt\@viiipt}
\renewcommand{\tiny}{\@setfontsize\tiny\@vipt\@viipt}
\renewcommand{\large}{\@setfontsize\large\@xiipt{14}}
\renewcommand{\Large}{\@setfontsize\Large\@xivpt{16}}
\renewcommand{\LARGE}{\@setfontsize\LARGE\@xviipt{20}}
\renewcommand{\huge}{\@setfontsize\huge\@xxpt{23}}
\renewcommand{\Huge}{\@setfontsize\Huge\@xxvpt{28}}
% sections with less space
\providecommand{\section}{}
\renewcommand{\section}{%
\@startsection{section}{1}{\z@}%
{-2.0ex \@plus -0.5ex \@minus -0.2ex}%
{ 1.5ex \@plus 0.3ex \@minus 0.2ex}%
{\large\bf\raggedright}%
}
\providecommand{\subsection}{}
\renewcommand{\subsection}{%
\@startsection{subsection}{2}{\z@}%
{-1.8ex \@plus -0.5ex \@minus -0.2ex}%
{ 0.8ex \@plus 0.2ex}%
{\normalsize\bf\raggedright}%
}
\providecommand{\subsubsection}{}
\renewcommand{\subsubsection}{%
\@startsection{subsubsection}{3}{\z@}%
{-1.5ex \@plus -0.5ex \@minus -0.2ex}%
{ 0.5ex \@plus 0.2ex}%
{\normalsize\bf\raggedright}%
}
\providecommand{\paragraph}{}
\renewcommand{\paragraph}{%
\@startsection{paragraph}{4}{\z@}%
{1.5ex \@plus 0.5ex \@minus 0.2ex}%
{-1em}%
{\normalsize\bf}%
}
\providecommand{\subparagraph}{}
\renewcommand{\subparagraph}{%
\@startsection{subparagraph}{5}{\z@}%
{1.5ex \@plus 0.5ex \@minus 0.2ex}%
{-1em}%
{\normalsize\bf}%
}
\providecommand{\subsubsubsection}{}
\renewcommand{\subsubsubsection}{%
\vskip5pt{\noindent\normalsize\rm\raggedright}%
}
% float placement
\renewcommand{\topfraction }{0.85}
\renewcommand{\bottomfraction }{0.4}
\renewcommand{\textfraction }{0.1}
\renewcommand{\floatpagefraction}{0.7}
\newlength{\@abovecaptionskip}\setlength{\@abovecaptionskip}{7\p@}
\newlength{\@belowcaptionskip}\setlength{\@belowcaptionskip}{\z@}
\setlength{\abovecaptionskip}{\@abovecaptionskip}
\setlength{\belowcaptionskip}{\@belowcaptionskip}
% swap above/below caption skip lengths for tables
\renewenvironment{table}
{\setlength{\abovecaptionskip}{\@belowcaptionskip}%
\setlength{\belowcaptionskip}{\@abovecaptionskip}%
\@float{table}}
{\end@float}
% footnote formatting
\setlength{\footnotesep }{6.65\p@}
\setlength{\skip\footins}{9\p@ \@plus 4\p@ \@minus 2\p@}
\renewcommand{\footnoterule}{\kern-3\p@ \hrule width 12pc \kern 2.6\p@}
\setcounter{footnote}{0}
% paragraph formatting
\setlength{\parindent}{\z@}
\setlength{\parskip }{5.5\p@}
% list formatting
\setlength{\topsep }{4\p@ \@plus 1\p@ \@minus 2\p@}
\setlength{\partopsep }{1\p@ \@plus 0.5\p@ \@minus 0.5\p@}
\setlength{\itemsep }{2\p@ \@plus 1\p@ \@minus 0.5\p@}
\setlength{\parsep }{2\p@ \@plus 1\p@ \@minus 0.5\p@}
\setlength{\leftmargin }{3pc}
\setlength{\leftmargini }{\leftmargin}
\setlength{\leftmarginii }{2em}
\setlength{\leftmarginiii}{1.5em}
\setlength{\leftmarginiv }{1.0em}
\setlength{\leftmarginv }{0.5em}
\def\@listi {\leftmargin\leftmargini}
\def\@listii {\leftmargin\leftmarginii
\labelwidth\leftmarginii
\advance\labelwidth-\labelsep
\topsep 2\p@ \@plus 1\p@ \@minus 0.5\p@
\parsep 1\p@ \@plus 0.5\p@ \@minus 0.5\p@
\itemsep \parsep}
\def\@listiii{\leftmargin\leftmarginiii
\labelwidth\leftmarginiii
\advance\labelwidth-\labelsep
\topsep 1\p@ \@plus 0.5\p@ \@minus 0.5\p@
\parsep \z@
\partopsep 0.5\p@ \@plus 0\p@ \@minus 0.5\p@
\itemsep \topsep}
\def\@listiv {\leftmargin\leftmarginiv
\labelwidth\leftmarginiv
\advance\labelwidth-\labelsep}
\def\@listv {\leftmargin\leftmarginv
\labelwidth\leftmarginv
\advance\labelwidth-\labelsep}
\def\@listvi {\leftmargin\leftmarginvi
\labelwidth\leftmarginvi
\advance\labelwidth-\labelsep}
% create title
\providecommand{\maketitle}{}
\renewcommand{\maketitle}{%
\par
\begingroup
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
% for perfect author name centering
\renewcommand{\@makefnmark}{\hbox to \z@{$^{\@thefnmark}$\hss}}
% The footnote-mark was overlapping the footnote-text,
% added the following to fix this problem (MK)
\long\def\@makefntext##1{%
\parindent 1em\noindent
\hbox to 1.8em{\hss $\m@th ^{\@thefnmark}$}##1
}
\thispagestyle{empty}
\@maketitle
\@thanks
%\@notice
\endgroup
\let\maketitle\relax
\let\thanks\relax
}
% rules for title box at top of first page
\newcommand{\@toptitlebar}{
\hrule height 2\p@
\vskip 0.25in
\vskip -\parskip%
}
\newcommand{\@bottomtitlebar}{
\vskip 0.29in
\vskip -\parskip
\hrule height 2\p@
\vskip 0.09in%
}
% create title (includes both anonymized and non-anonymized versions)
\providecommand{\@maketitle}{}
\renewcommand{\@maketitle}{%
\vbox{%
\hsize\textwidth
\linewidth\hsize
\vskip 0.8in
\@toptitlebar
\centering
{\LARGE\sc \@title\par}
\@bottomtitlebar
\vskip 0.5in
\textsc{\Large\undertitle}\\
\vskip 2.0in
\def\And{%
\end{tabular}\hfil\linebreak[0]\hfil%
\begin{tabular}[t]{c}\bf\rule{\z@}{24\p@}\ignorespaces%
}
\def\AND{%
\end{tabular}\hfil\linebreak[4]\hfil%
\begin{tabular}[t]{c}\bf\rule{\z@}{24\p@}\large\ignorespaces%
}
\begin{tabular}[t]{c}\bf\rule{\z@}{24\p@}\Large\@author\end{tabular}%
\vskip 1.0in \@minus 0.1in \center{\large\@date} \vskip 0.2in
}
}
% add conference notice to bottom of first page
\newcommand{\ftype@noticebox}{8}
\newcommand{\@notice}{%
% give a bit of extra room back to authors on first page
\enlargethispage{2\baselineskip}%
\@float{noticebox}[b]%
\footnotesize\@noticestring%
\end@float%
}
% abstract styling
\renewenvironment{abstract}
{
\centerline
{\large \bfseries \scshape Abstract}
\begin{quote}
}
{
\end{quote}
}
\endinput