\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{Paloma} \pdfinfo{ /Title (cs201-midterm-1.pdf) /Creator (Cheatography) /Author (Paloma) /Subject (CS201 Midterm 1 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}{12A39E} \definecolor{LightBackground}{HTML}{F0F9F8} \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{CS201 Midterm 1 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Paloma} via \textcolor{DarkBackground}{\uline{cheatography.com/55343/cs/14725/}}} \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}Paloma \\ \uline{cheatography.com/paloma} \\ \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 30th April, 2018.\\ 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{2.04673 cm} p{0.75186 cm} p{0.4177 cm} x{0.96071 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{Primitive Data Types}} \tn % Row 0 \SetRowColor{LightBackground} Type & \seqsplit{Description} & \seqsplit{Default} & Examples \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Boolean & \seqsplit{true/false} & false & boolean b = true; \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} char & \seqsplit{character} & 0 & char c = 'A'; \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} int- takes up less space than a double & \seqsplit{integer} & 0 & int i = 0; \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} double & \seqsplit{floating} point & 0.0 & double vel = 85.4; \tn % Row Count 10 (+ 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}{Memory}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/paloma_1525010144_Screen Shot 2018-04-29 at 9.55.13 AM.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Array: Length of array * memory of type it contains} \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}{Primitives vs Objects}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{- Java is an object oriented language -{}-\textgreater{} object oriented mean organized in terms of classes \newline % Row Count 2 (+ 2) - Primitive: can create them without using the new word \newline % Row Count 4 (+ 2) int x= 5; \newline % Row Count 5 (+ 1) - Objects: represented by a class and contain variables and methods \newline % Row Count 7 (+ 2) - Java has built-in objects, like String and ArrayList, but can also write your \newline % Row Count 9 (+ 2) own \newline % Row Count 10 (+ 1) - Objects are created by writing a class to represent them \newline % Row Count 12 (+ 2) String s = new String ("Hello world"); \newline % Row Count 13 (+ 1) - Object versions of all the primitive types because many data types require \newline % Row Count 15 (+ 2) you to say what is inside them \newline % Row Count 16 (+ 1) ArrayList\textless{}Integer\textgreater{} goodList = new ArrayList\textless{}Integer\textgreater{}(); \newline % Row Count 18 (+ 2) - One except are arrays. They are created by having the type the array \newline % Row Count 20 (+ 2) contains, followed by square brackets.% Row Count 21 (+ 1) } \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}{Static Methods}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{You can write code like Math.exp(-x{\emph{x/2) / Math.sqrt(2}}Math.PI) and Java knows what you mean. ) Static methods are associated \newline % Row Count 3 (+ 3) with the class. They can be called from static or dynamic methods. \newline % Row Count 5 (+ 2) No object \newline % Row Count 6 (+ 1) Static: associated with class \newline % Row Count 7 (+ 1) Dynamic: associated with instances of the class (objects) and have access to instance variables% Row Count 9 (+ 2) } \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}{Creating Data Types}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/paloma_1518735452_Screen Shot 2018-02-15 at 5.31.23 PM.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}{NBody}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Question 2: For what values of timeStep, does the simulation no longer behave correctly? \newline % Row Count 2 (+ 2) With a large totalTime and dt,the planets move in a spiral and some of the planets knock each other around during the simulation. \newline % Row Count 5 (+ 3) Large values don't work in the simulation because, the time step is too large. The planets don't \newline % Row Count 7 (+ 2) move fluidly and take large jumps from one position to the next.% Row Count 9 (+ 2) } \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}{Sets}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/paloma_1525096036_Screen Shot 2018-04-29 at 8.13.54 PM.jpeg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{s1.containsAll(s2) — returns true if s2 is a subset of s1. (s2 is a subset of s1 if set s1 contains all of the elements in s2.)} \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}{Arrays}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{type {[}{]} name = new type{[}size{]}; \newline Student {[}{]} studentList = new Student{[}3{]}; \newline Length \newline nameOfArray.length \newline Access value at a specific index \newline nameOfArray{[}index{]} \newline Convert List to array: Arrays.asList(ArrayList) \newline Homogenous collections: once created, don't grow} \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}{Constructors}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{A class contains constructors that are invoked to create objects from the class blueprint and have same name as class. Constructor declarations look like method declarations—except that they use the name of the class and have no return type. For example, Bicycle has one constructor: \newline \newline public Bicycle(int startCadence, int startSpeed, int startGear) \{ \newline gear = startGear; \newline cadence = startCadence; \newline speed = startSpeed; \newline \} \newline \newline Bicycle myBike = new Bicycle(30, 0, 8); \newline the call to new : \newline - calls the constructor, reference to the object \newline - all non primitive variables are pointers \newline -Calling constructor creates new object \newline To create a new Bicycle object called myBike, a constructor is called by the new operator:} \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}{Scanner Example Code}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{nextInt(), nextDouble(), and next() methods in the Scanner \newline \newline List\textless{}Set\textless{}String\textgreater{}\textgreater{} attendeeList(Scanner in) \{ \newline ArrayList\textless{}Set\textless{}String\textgreater{}\textgreater{} result = new ArrayList\textless{}Set\textless{}String\textgreater{}\textgreater{}(); \newline while (in.hasNext()) \{ \newline TreeSet\textless{}String\textgreater{} words = new TreeSet\textless{}String\textgreater{}(); \newline Scanner line = new Scanner(in.nextLine()); \newline while (line.hasNext()) \newline words.add(line.next()); \newline result.add(words); \newline \} \newline return result; \newline \}} \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}{Trade-offs}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Tree Maps and Tree Sets are slower but ordered \newline % Row Count 1 (+ 1) Hash Maps and Hash Sets are faster but unordered \newline % Row Count 2 (+ 1) ArrayList is slower and takes up more memory, but you can change the size \newline % Row Count 4 (+ 2) Array is faster and takes up less memory but you can't change the size% Row Count 6 (+ 2) } \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}{Comparing and Sorting}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Arrays.sort \newline % Row Count 1 (+ 1) Collections.sort \newline % Row Count 2 (+ 1) Strings are comparable lexicographically: zebra\textgreater{}aardvark but Zebra\textless{}aardvark \newline % Row Count 4 (+ 2) yak.compareTo(s) returns \textless{}0, ==0, \textgreater{}0% Row Count 5 (+ 1) } \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}{Equals Method Example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/paloma_1524940373_Screen Shot 2018-04-28 at 2.31.43 PM.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}{compareTo method example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/paloma_1524940407_Screen Shot 2018-04-28 at 2.31.50 PM.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}{Markov}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{- {\bf{EfficientMarkov }}based on using maps rather than rescanning the training text// Implement a new version of getFollows so that it's a constant time operation that uses myMap to return an ArrayList using the parameter to getFollows as a key. If the key isn't present in the map, throw a new NoSuchElementException with an appropriate String. \newline % Row Count 7 (+ 7) - {\bf{WordGram}} that will use a word-markov model rather than the character-markov model you start with \newline % Row Count 10 (+ 3) - {\bf{EfficientWordMarkov}}, modeled on EfficientMarkov and with the same structure in terms of methods -{}-{}- but using WordGram objects rather than Strings//This class uses a map (either a TreeMap or a HashMap) to create a more efficient version of WordMarkovModel. \newline % Row Count 16 (+ 6) The order of the Markov Model, size of the N gram, does not have more impact than the size of the text on the run time.% Row Count 19 (+ 3) } \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}{Map Interface}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{A Map is an object that maps keys to values. A map cannot contain duplicate keys: Each key can map to at most one value. Keys in a map need to be comparable% Row Count 4 (+ 4) } \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}{Adding Values to Maps}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Value is a counter \newline m.put(key, m.get(key) + 1) \newline \newline value is arrayList// set \newline if (map.get(key) == null) \{ \newline map.put(key, new ArrayList\textless{}Integer\textgreater{}()); \newline \} \newline map.put(key, \seqsplit{map.get(key).add(number));}} \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}{Maps API}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/paloma_1518753084_Screen Shot 2018-02-15 at 10.50.35 PM.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{value = map.get(key) \newline Collections.max} \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}{ArrayList}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Does not have fixed sized/ no primitive types \newline ArrayList\textless{}String\textgreater{} list = new ArrayList\textless{}String\textgreater{}(); \newline add(Object o) - adds an object to the ArrayList, must be of the correct type \newline remove(Object o) - removes that object from the ArrayList, if it exists \newline get(int index) - returns object at that index \newline contains(Object o) - returns true/false \newline size() - returns the length of the ArrayList} \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}{Object Values and Variables}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{== is usually used for primitive types / do they point to the same location in memory \newline % Row Count 2 (+ 2) while .equals() is used for objects.% Row Count 3 (+ 1) } \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}{Strings}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{String name = "word"; \newline String syntax \newline length() - returns length of String \newline charAt(int index) - returns character at that index \newline concat(String str) - cocatenates String str to the end of the String \newline compareTo(String stre) - compares the two Strings lexicographically \newline equals (Object obj) - compares the String to the object \newline indexOf(char c) - returns first index of the character c in the String} \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}{Hashing Markov Example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/paloma_1518754799_Screen Shot 2018-02-15 at 11.17.48 PM.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Instance of checks to see if the object is an instance of a class. Returns true if it is and returns false if it isn't. Hashing is important because it helps with efficiency (can access in O(1) time). While HashMaps already have a hash code, we overwrite it to make it more effective and so that ordering matters.} \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}{Inheritance: Implements vs. Etends.}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Object-oriented programming allows classes to inherit commonly used state and behavior from other classes.Implements you have to override all the methods. Extends is you add some methods to existing class.} \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}{Hash Code Example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{public int hashCode()\{ \newline int h = 0; \newline h += myState.hashCode() + myRegion.hashCode(){\emph{3; \newline for (int k=0, fact=9; k \textless{} myMembers.length; k++, fact }}= 3) \{ \newline h += \seqsplit{myMembers.hashCode()*fact;} \newline return h; \newline \}} \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}{Hashing}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{- Hashing is a search method: average case is O(1) search \newline % Row Count 2 (+ 2) - Associate a number with every key, use the number to store the key \newline % Row Count 4 (+ 2) - A hash function generates the number from the key \newline % Row Count 6 (+ 2) - Hash table is an array of fixed size with a key to each location and each key is mapped to an index in the table ArrayList\textless{}ArrayList\textless{}Type\textgreater{}\textgreater{}() \newline % Row Count 9 (+ 3) - Every object has a hashCode which is an integer value \newline % Row Count 11 (+ 2) - Two objects can have the same hashCode when two keys have the same value \newline % Row Count 13 (+ 2) - you can look for the next spot \newline % Row Count 14 (+ 1) - two equal objects should hash to the same place because they have the same hash code and key \newline % Row Count 16 (+ 2) - if x.equals(y) then x.hashCode() == y.hashCode()% Row Count 18 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}