\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{NoxLupus (NoxLupus)} \pdfinfo{ /Title (csc-202-test1-c.pdf) /Creator (Cheatography) /Author (NoxLupus (NoxLupus)) /Subject (CSC 202 Test1 C++ Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{076304} \definecolor{LightBackground}{HTML}{F7FAF7} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{CSC 202 Test1 C++ Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{NoxLupus (NoxLupus)} via \textcolor{DarkBackground}{\uline{cheatography.com/46432/cs/20762/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}NoxLupus (NoxLupus) \\ \uline{cheatography.com/noxlupus} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 18th October, 2019.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{\{\{fa-rebel\}\} Collections}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Definition}}: A data structure that stores a collection of objects (elements)} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{The elements within a collection are usually {\bf{organized}} based on: \{\{nl\}\} -Order in which they were {\bf{added}} \{\{nl\}\} -Some {\bf{inherent}} relationship} \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{They can be linear or nonlinear} \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Needs a well defined {\bf{interface}} to use properly} \tn % Row Count 8 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{For each collection we examine, we will {\bf{consider}}: \{\{nl\}\} - How does the collection {\bf{operate}} conceptually? \{\{nl\}\} - How do we formally {\bf{define its interface}}? \{\{nl\}\} - What kinds of problems does it help us {\bf{solve}}? \{\{nl\}\} - What ways might we {\bf{implement}} it? \{\{nl\}\} - What are the {\bf{benefits and costs}} of each implementation?} \tn % Row Count 15 (+ 7) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Operations}} that {\emph{define}} how we {\bf{interact}} with it: \{\{nl\}\}They usually {\bf{include ways for}} the user to: \{\{nl\}\}-{\bf{add and remove}} {\emph{elements, determine if the collection is {\bf{}}empty}}{\emph{, determine the collection's {\bf{}}size}} \{\{nl\}\}They also may include: \{\{nl\}\}-{\bf{iterators}}{\emph{, to process each element in the collection, operations that {\bf{}}interact}} with {\bf{other}}{\emph{ collections}}} \tn % Row Count 23 (+ 8) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{SET}} -\textgreater{} random selectoin, no orrder, no duplicates} \tn % Row Count 25 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{STACK}} -\textgreater{} first in last out, adds to top, takes off top} \tn % Row Count 27 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{QUEUE}} -\textgreater{} first in first out, adds to back, takes off frount} \tn % Row Count 29 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Rank}} and {\bf{Position}} are 2 {\emph{different}} ways to define the location of a particular element within the container} \tn % Row Count 32 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-For example, a list of {\bf{people}} may be kept in {\bf{alphabetical}} order by name or in the order in which they were {\bf{added}} to the list \newline -Which type of collection you {\bf{use depends}} on what you are trying to {\bf{accomplish}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Dynamic Memory and "new"}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The operator {\bf{new dynamically}} allocates memory from the {\bf{heap}} (free memory) and returns a pointer} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`Candidate *c; //creates a pointer variable for Candidate structures \{\{nl\}\}c = new Candidate; //actually allocates the memory for a Candidate data type`} \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The new object will exist until it is explicitly de-allocated (no garbage collection!)\{\{nl\}\}`delete Foo;`} \tn % Row Count 10 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Arrays}} can also be dynamically allocated in the same way, but must be de-allocated using the `delete{[}{]}`} \tn % Row Count 13 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{If it has a `new` it needs a `delete`}} \newline It is essential to eventually de-allocate memory using delete that was allocated with new to avoid memory leaks, {\emph{once the pointer is gone you cant access it}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Analysis Tools}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Write program and run it\{\{nl\}\} clock it and plot it \{\{nl\}\} {\bf{Time X Input Size}}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{We use the {\bf{Worst Case}} not the Average Case \{\{nl\}\} lo~ ~ {\emph{Easier to analyze Crucial to applications such as games, finance and robotics}}} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Time is in unets were 1 is the time it would take for that RAM to acsess on pease of memory} \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{By inspecting the pseudocode, we can determine the maximum number of primitive operations executed by an algorithm, as a function of the input size:} \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{1.) count up primative opps, a loop from `i\textless{}-1 to n-1` is `2n`\{\{nl\}\}2.) count each line up(adding them)`8n-3`\{\{nl\}\}3.) then take the fastest growing part `8n`} \tn % Row Count 14 (+ 4) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-{}-Growth Rate-{}-}}} \tn % Row Count 15 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{T(n) is afected by the hardwaer but the growth rate dose not chang, {\emph{growth rate is inhearet to the funtoin}}} \tn % Row Count 18 (+ 3) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Growth rate is not afected by consatnts or lower odder terms} \tn % Row Count 20 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{It's not usually {\bf{necessary to know the exact}} growth function. The key issue is the {\bf{asymptotic complexity}} {\emph{(how it grows as n increases)}}. This is determined by the {\bf{dominant term}} in the growth function \{\{nl\}\}This is referred to as the {\bf{order}} of the algorithm. We often use {\bf{Big-Oh}} notation to specify the order} \tn % Row Count 27 (+ 7) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-{}-Asymptotic Algorithm Analysis-{}-}}} \tn % Row Count 28 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The asymptotic analysis of an algorithm determines the {\bf{running time}} {\emph{in big-Oh notation}}} \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Analysis Tools (cont)}} \tn % Row 11 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The asymptotic analysis: \{\{nl\}\}1.) We find the worst-case number of primitive operations executed as a function n(input size) \{\{nl\}\}2.) We express this function with big-Oh notation} \tn % Row Count 4 (+ 4) % Row 12 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-{}-Big-Oh-{}-}}} \tn % Row Count 5 (+ 1) % Row 13 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{If is f(n) is of degree d, then f(n) is {\bf{O(n\textasciicircum{}d\textasciicircum{})}} \{\{nl\}\}-Use the smallest possible class of functions \{\{nl\}\}-Use the simplest expression of the class} \tn % Row Count 9 (+ 4) % Row 14 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{\textasciitilde{}Loops\textasciitilde{}}}\{\{nl\}\}-A {\bf{loop executes}} a certain number of times: n \{\{nl\}\}-It contains the inner complexity of: m \{\{nl\}\}Then the loop's {\bf{complexity}} is n*m \{\{nl\}\} ~ ~ If m is a {\bf{constant}} -\textgreater{} O(n) \{\{nl\}\} ~ ~ If m is a {\bf{function of n}}(like another loop(n, n-1 or n/2)) -\textgreater{} O(n*m){\emph{(simplified)}}} \tn % Row Count 16 (+ 7) % Row 15 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{\textasciitilde{}Recursive\textasciitilde{}}}\{\{nl\}\}-The {\bf{size}} of the problem is: n \{\{nl\}\} -{\emph{Except for the base case}}, each {\bf{recursive call}} results in calling itself m more: m-1 \{\{nl\}\} So the {\bf{complexity}} is m\textasciicircum{}n\textasciicircum{}-1 or O(m\textasciicircum{}n\textasciicircum{})} \tn % Row Count 21 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-We pretend the memory is unlimited \newline -{\emph{(Big-Oh)Since constant factors and lower-order terms are eventually dropped we can skip counting primitive operations}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Double Linked List Insertoin Algorithom}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/noxlupus_1571194611_DDL Intertion.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.54287 cm} x{3.43413 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Terms}} \tn % Row 0 \SetRowColor{LightBackground} data type & the programming constructs used to implement a collection \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} abstract data type & a data type whose values and operations are not inherently defined in a programming language \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} data structure & a group of values and the operations defined on those values \tn % Row Count 10 (+ 3) % Row 3 \SetRowColor{white} Algorithm & a step-by-step procedure for preforming some task in a finite amount of time \tn % Row Count 13 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Abstraction}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{An abstraction hides certain details at certain times} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{It provides a way to deal with the complexity of a large system} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{A collection, like any well-defined object, is an abstraction} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{We want to separate the interface of the collection (how we interact with it) from the underlying details of how we choose to implement it} \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.14471 cm} x{3.83229 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data Types}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Enumerations} & User defined types for discrete values (behave much like integers) Default, numbered 0, 1, etc, but can specify values {\emph{\{\{nl\}\}enum Day \{ WINTER, SPRING, SUMMER, FALL \} ; \{\{nl\}\}enum Day \{ FALL = 3, WINTER = 2, SUMMER = 1, SPRING = 4 \} ;}} \tn % Row Count 8 (+ 8) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Abstract Data Types (ADTs)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Is an abstraction of a data structure}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{An ADT {\bf{specifies}}: \{\{nl\}\}-{\bf{Data}} stored \{\{nl\}\}- {\bf{Operations}} on the data \{\{nl\}\}- {\bf{Error conditions}} associated with operations} \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{No specification of how, just a list of operations. We should {\bf{hide the implementation}} . . . The user of the ADT does {\bf{not}} need to know the {\bf{details}}, {\bf{just}} how to {\bf{use}} it. {\emph{Implementations may change}} due to hardware or system upgrades{\emph{user doesn't need to see that}}} \tn % Row Count 10 (+ 6) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{The {\bf{container}} (the data structure), and how that container is {\bf{manipulated}}, is in many ways {\bf{more important}} than the actual {\bf{data}}. {\bf{Templates}} allow C++ programs to manipulate {\bf{many different types}} of data using the {\bf{same semantics}}.} \tn % Row Count 16 (+ 6) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-Templates-}} allow C++ programs to manipulate {\bf{many different types}} of data using the {\bf{same semantics}}.} \tn % Row Count 19 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Example}}: ADT modeling a simple stock trading system: \{\{nl\}\}~ -The data {\bf{stored}} are buy/sell orders \{\{nl\}\}~ -The {\bf{operations}} supported are \{\{nl\}\}~ ~ ~ ~ order {\bf{buy}}(stock, \{\{nl\}\}~ ~ shares, price) \{\{nl\}\}~ ~ ~ ~ order {\bf{sell}}(stock, shares, price) \{\{nl\}\}~ ~ ~ ~ void {\bf{cancel}}(order) \{\{nl\}\}~ -{\bf{Error}} conditions: \{\{nl\}\}~ ~ ~ ~ Buy/sell a {\bf{nonexistent}} stock \{\{nl\}\}~ ~ ~ ~ Cancel a {\bf{nonexistent}} order} \tn % Row Count 30 (+ 11) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{template\textless{}typename E\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{POINTERS}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{*}} - dereferencing (accesses the objects value {\bf{from}} its {\bf{address}})} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{\&}} - {\bf{address of}} (returns the address of an object in memory)} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{Example: if int x, then \&x will return the address of the x variable}}\{\{nl\}\}{\emph{Example: if int* q, then q = \&x and you can use *q = 5 effectively changes the value of x.}}} \tn % Row Count 8 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`\{\{nl\}\}int a = \{12,15,18\}; //initializes the array a with size 3, index positions 0-2, and \{\{nl\}\} //values 12, 15 and 18 \{\{nl\}\}Int* p = a; //p points to a{[}0{]} \{\{nl\}\}Int* q = \&c{[}0{]}; //q also points to a{[}0{]}`} \tn % Row Count 13 (+ 5) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{pointer and arrays}}} \tn % Row Count 14 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{int *r{[}17{]}; creates an array of 17 int pointer elements{\emph{ \{\{nl\}\}Once the array has been initialized, you can dereference any particular pointer\{\{nl\}\}}}*r{[}6{]} will dereference the 7th pointer in the array*} \tn % Row Count 19 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Rank}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Is {\bf{defined}} as the {\bf{location}} of an element within its container} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{first rank is 1 {\emph{not 0}}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The index is typically one less than the rank.} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{The {\bf{index}} value typically indicates how many elements precede that particular element\{\{nl\}\} the {\bf{Rank}} shows what spont it is in} \tn % Row Count 7 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Used in {\bf{Vectors}}{\emph{(it's really like indext it just shows what it is at not how manny more there are)}}} \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Position}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The concept of Position models the notion of {\bf{place within a data structure}} where a single object is stored \{\{nl\}\}{\emph{Does not rely on the idea of rank}}} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{The Position ADT has one {\bf{method}}: \{\{nl\}\}Object {\bf{p.element}}(): returns the element at {\bf{position}} p \{\{nl\}\}In C++ it is convenient to implement this as {\bf{*p}}} \tn % Row Count 8 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{Like nabors}} consers {\bf{what is around}} not were it is} \tn % Row Count 10 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Useed in {\bf{Nodes}} {\emph{(shows what it is colsed to, but not nesarly were it is)}}} \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{OVERALL VIEW}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/noxlupus_1571324690_Inkodo-10172019_110328_AM.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Stack ADT}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The Stack ADT stores arbitrary objects} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Insertions and deletions follow the {\bf{last-in first-out}} scheme \{\{nl\}\} Think of a {\bf{spring-loaded dispenser}}} \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-{}-Main stack operations-{}-}}: \{\{nl\}\} ~ ~ {\bf{push}}(object): inserts an element \{\{nl\}\} ~ ~ object {\bf{pop}}(): removes the last inserted element} \tn % Row Count 8 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-{}-Auxiliary stack-{}-}} operations: \{\{nl\}\} ~ ~ {\bf{object top}}(): returns the last inserted element without removing it \{\{nl\}\} ~ ~ integer {\bf{size}}(): returns the number of elements stored \{\{nl\}\} ~ ~ boolean {\bf{empty}}(): indicates whether no elements are stored} \tn % Row Count 14 (+ 6) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{pop -\textgreater{} - \{\{nl\}\} push -\textgreater{} +}}} \tn % Row Count 15 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{C++ interface corresponding to our Stack ADT Uses an exception class StackEmpty Different from the built-in C++ STL class stack} \tn % Row Count 18 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-Direct applications: \newline \{\{nl\}\} ~ ~ Page-visited {\bf{history}} in a Web browser \newline \{\{nl\}\} ~ ~ {\bf{Undo sequence}} in a text editor \newline \{\{nl\}\} ~ ~ Chain of method calls in the {\bf{C++ run-time system}} \newline \{\{nl\}\} -Indirect applications: \newline \{\{nl\}\} ~ ~ {\emph{Auxiliary data structure for algorithms \newline \{\{nl\}\} ~ ~ Component of other data structures}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Queue ADT}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Stores arbitrary objects} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Insertions and deletions follow the first-in first-out scheme \{\{nl\}\}Insertions are at the rear of the queue and removals are at the front of the queue} \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-Main queue operations- \{\{nl\}\}~ ~ {\bf{enqueue}}(object): inserts an element at the end of the queue \{\{nl\}\}~ ~ {\bf{Dequeue}}(): removes the element at the front of the queue} \tn % Row Count 8 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{-Auxiliary queue- operations: \{\{nl\}\}~ ~ object {\bf{front}}(): returns the element at the front without removing it \{\{nl\}\}~ ~ integer s{\bf{ize}}(): returns the number of elements stored \{\{nl\}\}~ ~ boolean {\bf{empty}}(): indicates whether no elements are stored} \tn % Row Count 14 (+ 6) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-Exceptions- \{\{nl\}\}~ ~ Attempting the execution of dequeue or front on an empty queue throws an QueueEmpty} \tn % Row Count 17 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{enqueue -\textgreater{} + \{\{nl\}\} dequeue -\textgreater{} - \{\{nl\}\} head -\textgreater{} }}retuns top(dose not chang anything)} \tn % Row Count 19 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{C++ interface corresponding to our Queue ADT Requires the def-inition of exception QueueEmpty No corresponding built-in C++ class} \tn % Row Count 22 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-Direct applications \{\{nl\}\} ~ ~ {\bf{Waiting lists}}, bureaucracy \{\{nl\}\} ~ ~ Access to {\bf{shared resources}} (e.g., printer) \{\{nl\}\} ~ ~ Multiprogramming \{\{nl\}\}-Indirect applications \{\{nl\}\} ~ ~ Auxiliary data structure for algorithms \{\{nl\}\} ~ ~ Component of other data structures} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Deque ADT}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{stores arbitrary objects} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Insertions and deletions can be done to the front OR the back of the deque} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-Main queue operations- \{\{nl\}\}~ ~ {\bf{insertFront}}(object): inserts an element at the front of the deque \{\{nl\}\}~ ~ {\bf{insertBack}}(object): inserts an element at the back of the deque \{\{nl\}\}~ ~ {\bf{eraseFront}}(): removes the first element of the deque \{\{nl\}\}~ ~ {\bf{eraseBack}}(): removes the last element of the deque} \tn % Row Count 11 (+ 8) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{-Auxiliary deque operations- \{\{nl\}\}~ ~ object {\bf{front}}(): returns the element at the front without removing it \{\{nl\}\}~ ~ object {\bf{back}}(): returns the element at the back without removing it \{\{nl\}\}~ ~ integer {\bf{size}}(): returns the number of elements stored \{\{nl\}\}~ ~ boolean {\bf{empty}}(): indicates whether no elements are stored} \tn % Row Count 19 (+ 8) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-Exceptions- \{\{nl\}\}~ ~ Attempting the execution of eraseFront, eraseBack, front or back on an empty deque throws an DequeEmptyException} \tn % Row Count 22 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{insertFront -\textgreater{} + \{\{nl\}\}insertBack -\textgreater{} + \{\{nl\}\}eraseFront -\textgreater{} -\{\{nl\}\} eraseBack -\textgreater{} - \{\{nl\}\} front ~~~~~~~ -\textgreater{} }}retuns the frount element(dose not chang anything){\bf{\{\{nl\}\}back ~~~~~~~ -\textgreater{} }}retuns the back element(dose not chang anything)} \tn % Row Count 29 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{can be used as a stack and as a queue} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Array List(Vector)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The {\bf{Vector or Array List}} ADT extends the notion of array by {\bf{storing a sequence of objects}}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{-{}-{\bf{Main methods}}-{}- \{\{nl\}\}{\bf{At}}(integer i): returns the element {\bf{at index i without removing}} it \{\{nl\}\}{\bf{Set}}(integer i, object o): {\bf{replace}} the element at index i with o \{\{nl\}\}{\bf{Insert}}(integer i, object o): {\bf{insert}} a new element o to have index i \{\{nl\}\}{\bf{Erase}}(integer i): {\bf{removes}} element at index i} \tn % Row Count 9 (+ 7) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-{}-{\bf{Additional methods}}-{}- \{\{nl\}\}{\bf{Size}}() \{\{nl\}\}{\bf{Empty}}()} \tn % Row Count 11 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{An element can be {\bf{accessed, inserted or removed}} by specifying its {\bf{index}} (number of elements preceding it)} \tn % Row Count 14 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{An {\bf{exception}} is thrown if an incorrect index is given (e.g., a negative index)} \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{A {\bf{major weakness}} in array implementations of collections is the {\bf{fixed capacity}} N for the number of elements that may be stored in the array. \newline Thus we double the array size when the array is full} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Iterators}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{extends the concept of position by adding a traversal capability} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{An iterator behaves like a pointer to an element \{\{nl\}\}{\bf{*p -\textgreater{} returns the element}} referenced by this {\emph{iterator}} \{\{nl\}\}{\bf{++p -\textgreater{} advances}} to the {\emph{next element}} \{\{nl\}\}{\bf{-{}-p -\textgreater{} regresses}} to the {\emph{previous element}}} \tn % Row Count 7 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Node List}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The Node List ADT models a {\bf{sequence of positions}} storing arbitrary objects} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{-{}-{\bf{Generic methods}}-{}- \{\{nl\}\} size(), \{\{nl\}\} empty()} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-{}-{\bf{Iterators}}-{}- \{\{nl\}\}begin(), end()} \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{-{}-{\bf{Update methods}}-{}- \{\{nl\}\} insertFront(e), \{\{nl\}\} insertBack(e) \{\{nl\}\} removeFront(), \{\{nl\}\} removeBack()} \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-{}-{\bf{Iterator-based update}}-{}- \{\{nl\}\} insert(p, e) \{\{nl\}\} remove(p)} \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{It establishes a {\bf{before/after relation}} between {\emph{positions}}} \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Sequences}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The Sequence ADT is the {\bf{union}} of the {\bf{Array}} List and {\bf{Node}} List ADTs} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{-{}-{\bf{Generic methods}}- \{\{nl\}\}size(), \{\{nl\}\} empty()} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-{}-{\bf{ArrayList-based methods}}-{}- \{\{nl\}\} at(i), \{\{nl\}\} set(i, o), \{\{nl\}\} insert(i, o), erase(i)} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{-{}-{\bf{List-based methods}}-{}- \{\{nl\}\} begin(), \{\{nl\}\} end() \{\{nl\}\} insertFront(o), \{\{nl\}\} insertBack(o) \{\{nl\}\} eraseFront(), \{\{nl\}\} eraseBack() \{\{nl\}\} insert (p, o), \{\{nl\}\} erase(p)} \tn % Row Count 10 (+ 4) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-{}-{\bf{Bridge methods}}- \{\{nl\}\} atIndex(i), \{\{nl\}\} indexOf(p)} \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The Sequence ADT is a basic, {\bf{general-purpose, data structure}} for storing an {\bf{ordered}} collection of elements} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}