\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{Randomgirlll13} \pdfinfo{ /Title (data-structures.pdf) /Creator (Cheatography) /Author (Randomgirlll13) /Subject (Data Structures 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}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \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{Data Structures Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Randomgirlll13} via \textcolor{DarkBackground}{\uline{cheatography.com/186328/cs/39159/}}} \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}Randomgirlll13 \\ \uline{cheatography.com/randomgirlll13} \\ \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 1st August, 2023.\\ 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{tabularx}{17.67cm}{x{7.2534 cm} x{10.0166 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Selection Sort}} \tn % Row 0 \SetRowColor{LightBackground} What is Selection Sort? & It is a Simple and efficient algorithm that works by repeatedly selecting the smallest (or largest) element from the unsorted portion of the list and moving it to the sorted portion of the List \tn % Row Count 9 (+ 9) % Row 1 \SetRowColor{white} How does Selection Sort work? & You first start with an Unsorted List \{\{nl\}\} {[}64,25,12,22,11{]} \{\{nl\}\} - It will first check the 0th element, 64, 64 is larger than 25, 25 is larger than 12, 12 is smaller than 22, an 12 is larger than 11. Since 11 is the smallest value found in the list starting from 64, 64 will swap locations with 11. The list is now {[}11,25,12,22,64{]} \{\{nl\}\} - The second step is to look at the 1st element of the list, 25, 25 is larger than 12, 12 is smaller than 22, 12 is smaller than 64, making 12 the next smallest element. The list is now {[}11,12,25,22,64{]} \{\{nl\}\} - This will continue until the list is completely sorted. The list will end up as {[}11,12,22,25,64{]} \tn % Row Count 38 (+ 29) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.2534 cm} x{10.0166 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Selection Sort (cont)}} \tn % Row 2 \SetRowColor{LightBackground} Advantages and Disadvantages & Advantages \{\{nl\}\} - It is simple and easy \{\{nl\}\} - It works well with small datasets \{\{nl\}\} Disadvantages \{\{nl\}\} - It has O(N\textasciicircum{}2) Time Complexity \{\{nl\}\} - It does not do well with large datasets \{\{nl\}\} - It does not preserve the order of items with equal keys, meaning it is not stable \tn % Row Count 13 (+ 13) % Row 3 \SetRowColor{white} Time Complexity & O(N\textasciicircum{}2) \tn % Row Count 14 (+ 1) % Row 4 \SetRowColor{LightBackground} Auxillary Space & O(1) \tn % Row Count 15 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Disjoint Set}} \tn % Row 0 \SetRowColor{LightBackground} What is a Disjoint Set? & Two sets are called disjoint sets if they don't have any elements in common, therefore the intersection of the sets is a null set \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} What is a Disjoint Set Data Structure? & A Disjoint Set Data Structure Stores non-overlapping or disjoint subsets of elements. \tn % Row Count 12 (+ 5) % Row 2 \SetRowColor{LightBackground} What does this Data Structure Support? & This supports \{\{nl\}\} - Adding new sets to the disjoint set \{\{nl\}\} - Merging disjoint sets to a single disjoint set using a Union Operation \{\{nl\}\} - Finding Representation of a disjoint set using the Find operation \{\{nl\}\} - The ability to check if two sets are disjoint or not \tn % Row Count 26 (+ 14) % Row 3 \SetRowColor{white} An Example & We are given 10 individuals: a, b, c, d, e, f, g, h, i, j \{\{nl\}\} The following relationships are found among them: \{\{nl\}\} a \textless{}-\textgreater{} b \{\{nl\}\} b \textless{}-\textgreater{} d \{\{nl\}\} c \textless{}-\textgreater{} f \{\{nl\}\} c \textless{}-\textgreater{} i \{\{nl\}\} j \textless{}-\textgreater{} e \{\{nl\}\} g \textless{}-\textgreater{} j \{\{nl\}\} Given the information of whether an individual is a friend of another or not we can divide them into 4 sub groups. \{\{nl\}\} g1 = \{ a, b, d\} \{\{nl\}\} g2 = \{c, f, i\} \{\{nl\}\} g3 = \{e, g, j\} \{\{nl\}\} g4 = \{h\} \tn % Row Count 47 (+ 21) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Disjoint Set (cont)}} \tn % Row 4 \SetRowColor{LightBackground} Data Structures that are used within the Disjoint Set Data Structure & An Array: \{\{nl\}\} There is an array of integers that we call Parent{[}{]}. If there are N items. The i'th elemth of the array represents the i'th item. More specifically, the i'th element of the Parent{[}{]} array is the parent of the i'th item. These relationships create one or more virtual trees. \{\{nl\}\} The other Data Sructure is a Tree representing the Disjoint Set: \{\{nl\}\} If two elements are in the same tree, then they are in the same Disjoint Set. The root node (The topmost node) of each tree is called the representative of the set. There is always one single Unique representative of eachset. A simple rule to help identify a representative is if "i" is the representative of a set, the Parent{[}i{]} = i. If "i" isn't the representative, it can be found by traveling up the tree. \tn % Row Count 39 (+ 39) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Disjoint Set (cont)}} \tn % Row 5 \SetRowColor{LightBackground} Operations this data structure has & Find: This can be implemented by recursively traversing the Parent{[}{]} array until we hit a node that is the parent itself. \{\{nl\}\} Union: This will take 2 elements and it will find the representatives of their sets using the find operation (previously mentioned), and it will finaly put either on of the trees under the root node of the other tree. This effectively merges the trees and sets \tn % Row Count 20 (+ 20) % Row 6 \SetRowColor{white} Time Complexity & Creating Single Item Sets: O(N) \{\{nl\}\} Union and Set Operations: O(Log N) \{\{nl\}\} Overall: O(N +Log N) \tn % Row Count 26 (+ 6) % Row 7 \SetRowColor{LightBackground} Space Complexity & O(N) \tn % Row Count 27 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Greedy Algorithm}} \tn % Row 0 \SetRowColor{LightBackground} What is the Greedy Algorithm? & The Greedy Algorithm is an Algorithm paradigm that builds up a solution piece by piece. This will always choose the next piece that offers the most obvious and immediate benefit. This does not consider the overall optimal result. \tn % Row Count 12 (+ 12) % Row 1 \SetRowColor{white} Key Features & - Works in a top-down approach and will not reverse a previous decision \{\{nl\}\} - Always goes for the local best choice to produce the global best result \tn % Row Count 20 (+ 8) % Row 2 \SetRowColor{LightBackground} How to determine if the Greedy Algorithm Should be used & 1. Greedy Choice Property: \{\{nl\}\} If an optimal solution to the problem can be found by choosing the best choice at each step without reconsidering the previous step chosen. \{\{nl\}\} 2. Optimal Substructure: \{\{nl\}\} If the oprimal overall solution corresponds to the optimal solution to the subproblems \tn % Row Count 35 (+ 15) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Greedy Algorithm (cont)}} \tn % Row 3 \SetRowColor{LightBackground} Advantages and Disadvantages & Advantages: \{\{nl\}\} - The Algorithm is easier to describe \{\{nl\}\} - It can preform better than other algorithm when placed in the correct situation \{\{nl\}\} Disadvantages: \{\{nl\}\} - Doesn't always produce the optimal solution \tn % Row Count 11 (+ 11) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Kruskal's Minimum Spanning Tree (MST) Algorithm}} \tn % Row 0 \SetRowColor{LightBackground} What is a Minimum Spanning Tree? & A Minimum Spanning Tree/Minimum Weight Spanning Tree for a weighted, connected, undirected graph is a spanning tree with a weight less than or equal to the weight of every other spanning tree \tn % Row Count 10 (+ 10) % Row 1 \SetRowColor{white} What is a Spanning Tree? & A spanning tree is a subset of a given graph which has all the vertices covered with the minimum possible number of edges. \{\{nl\}\} A spanning tree does not have any cycles and cannot be disconnected \tn % Row Count 20 (+ 10) % Row 2 \SetRowColor{LightBackground} Steps to finding MST using the Kruskal Algorithm & 1. Sort all the edges in non-decreasing order by their weight \{\{nl\}\} 2. Pick the smallest edge and check if it forms a cycle with the spanning tree formed so far. If it doesn't keep the edge and add it to the spanning tree, if it does, discard the edge. \{\{nl\}\} 3. Repeat step 2 until there are (vertices - 1) edges in the spanning tree \tn % Row Count 37 (+ 17) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Kruskal's Minimum Spanning Tree (MST) Algorithm (cont)}} \tn % Row 3 \SetRowColor{LightBackground} Time Complexity & O(E {\emph{ LogE) or Log(E }} LogV) \tn % Row Count 2 (+ 2) % Row 4 \SetRowColor{white} Auxiliary Space & O(V + E) \{\{nl\}\} V is the number of vertices within the given graph \{\{nl\}\} E is the number of edges within the given graph \tn % Row Count 9 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{All Pairs Shortest Path - Floyd Warshall Algorithm}} \tn % Row 0 \SetRowColor{LightBackground} What is it? & It is an Algorithm to find the shortest distance between every pair of vertices in a given edge-weighted directed graph \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} What approach does it follow? & This algorithm follows the dynamic programming approach to find the shortest path \tn % Row Count 11 (+ 5) % Row 2 \SetRowColor{LightBackground} How to accomplish the task using the algorithm & Steps \{\{nl\}\} 1. Initialize a solution matrix \tn % Row Count 14 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.5264 cm} x{11.7436 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Single Source Shortest Path - Dijkstra's Algorithm}} \tn % Row 0 \SetRowColor{LightBackground} What is it? & An Algorithm used to find the shortest paths from the source to all vertices in the given graph \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} What are the steps? & Steps \{\{nl\}\} 1. Create a sptSet (Shortest Path Tree Set). This will keep track of vertices included in the SPT whose minimum distance from the source is calculated and finalized. Initilize as empty \{\{nl\}\} 2. Assign distance values to all vertices in the input graph. Inilize all distance values as INFINITE except the source vertex which is 0, this is so it will be picked first. \{\{nl\}\} 3. While the sptSet doesn't include all vertices \{\{nl\}\} - Pick a vertex U that is not in the sptSet and has a minimum distance value \{\{nl\}\} - Include U into the sptSet \{\{nl\}\} - Update the distance values of all adjacent vertices of U \{\{nl\}\} -{}- To update, iterate through all adjacent vertices \{\{nl\}\} -{}- For every adjacent vertex of V, if the sum of the distance value of U (from source) and weight of edge U-V, is less than the distance value of V, then update the distance value of V. \{\{nl\}\} \{\{nl\}\} Note: Use a boolean array sptSet{[}{]} to represent the set of vertices in SPT. If a value of sptSet{[}V{]} is true, then vertex V is included in SPT \tn % Row Count 43 (+ 39) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.5264 cm} x{11.7436 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Single Source Shortest Path - Dijkstra's Algorithm (cont)}} \tn % Row 2 \SetRowColor{LightBackground} Time Complexity & O(V\textasciicircum{}2) \tn % Row Count 2 (+ 2) % Row 3 \SetRowColor{white} Auxillary Space & O(V) \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.5988 cm} x{9.6712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Binary Search Trees}} \tn % Row 0 \SetRowColor{LightBackground} What are they? & Binary search trees are node-based binary tree data structures which have the following properties \{\{nl\}\} - The left subtrees of nodes contain only nodes with keys lesser than a node's key \{\{nl\}\} - The right subtrees of nodes contain only nodes with keys greater than a node's key \{\{nl\}\} - The left and right subtree each must also be a binary search tree \{\{nl)\}\} \{\{nl\}\} Note: There may be no duplicates within the tree \tn % Row Count 20 (+ 20) % Row 1 \SetRowColor{white} Inserting a node into a BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 23 (+ 3) % Row 2 \SetRowColor{LightBackground} Inorder Traversal & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 26 (+ 3) % Row 3 \SetRowColor{white} Preorder Traversal & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 29 (+ 3) % Row 4 \SetRowColor{LightBackground} Postorder Traversal & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.5988 cm} x{9.6712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Binary Search Trees (cont)}} \tn % Row 5 \SetRowColor{LightBackground} Level Order Traversal & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 3 (+ 3) % Row 6 \SetRowColor{white} Print Nodes at Given Level & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 6 (+ 3) % Row 7 \SetRowColor{LightBackground} Print Nodes at Given Leaf & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 9 (+ 3) % Row 8 \SetRowColor{white} Print all non-Leaf nodes & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 12 (+ 3) % Row 9 \SetRowColor{LightBackground} Right View of BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 15 (+ 3) % Row 10 \SetRowColor{white} Left View of BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 18 (+ 3) % Row 11 \SetRowColor{LightBackground} Height of BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 21 (+ 3) % Row 12 \SetRowColor{white} Delete a Node of BST & Time Complexity: O(Log N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 24 (+ 3) % Row 13 \SetRowColor{LightBackground} Smallest Node of the BST & Time Complexity: O(Log N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 27 (+ 3) % Row 14 \SetRowColor{white} Total Number of Nodes in the BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.5988 cm} x{9.6712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Binary Search Trees (cont)}} \tn % Row 15 \SetRowColor{LightBackground} Delete a BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 3 (+ 3) % Row 16 \SetRowColor{white} Advantages and Disadvantages & Advantages \{\{nl\}\} \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.5988 cm} x{9.6712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Binary Search Trees}} \tn % Row 0 \SetRowColor{LightBackground} What are they? & Binary search trees are node-based binary tree data structures which have the following properties \{\{nl\}\} - The left subtrees of nodes contain only nodes with keys lesser than a node's key \{\{nl\}\} - The right subtrees of nodes contain only nodes with keys greater than a node's key \{\{nl\}\} - The left and right subtree each must also be a binary search tree \{\{nl)\}\} \{\{nl\}\} Note: There may be no duplicates within the tree \tn % Row Count 20 (+ 20) % Row 1 \SetRowColor{white} Inserting a node into a BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 23 (+ 3) % Row 2 \SetRowColor{LightBackground} Inorder Traversal & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 26 (+ 3) % Row 3 \SetRowColor{white} Preorder Traversal & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 29 (+ 3) % Row 4 \SetRowColor{LightBackground} Postorder Traversal & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.5988 cm} x{9.6712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Binary Search Trees (cont)}} \tn % Row 5 \SetRowColor{LightBackground} Level Order Traversal & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 3 (+ 3) % Row 6 \SetRowColor{white} Print Nodes at Given Level & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 6 (+ 3) % Row 7 \SetRowColor{LightBackground} Print Nodes at Given Leaf & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 9 (+ 3) % Row 8 \SetRowColor{white} Print all non-Leaf nodes & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 12 (+ 3) % Row 9 \SetRowColor{LightBackground} Right View of BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 15 (+ 3) % Row 10 \SetRowColor{white} Left View of BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 18 (+ 3) % Row 11 \SetRowColor{LightBackground} Height of BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 21 (+ 3) % Row 12 \SetRowColor{white} Delete a Node of BST & Time Complexity: O(Log N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 24 (+ 3) % Row 13 \SetRowColor{LightBackground} Smallest Node of the BST & Time Complexity: O(Log N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 27 (+ 3) % Row 14 \SetRowColor{white} Total Number of Nodes in the BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.5988 cm} x{9.6712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Binary Search Trees (cont)}} \tn % Row 15 \SetRowColor{LightBackground} Delete a BST & Time Complexity: O(N) \{\{nl\}\} Auxillary Space: O(1) \tn % Row Count 3 (+ 3) % Row 16 \SetRowColor{white} Advantages and Disadvantages & Advantages \{\{nl\}\} - Fast Search \{\{nl\}\} - In Order Traversal \{\{nl\}\} - Space Efficient \{\{nl\}\} Disadvantages \{\{nl\}\} - Skewed Trees \{\{nl\}\} - Additional Time Required \{\{nl\}\} - Efficiency \tn % Row Count 12 (+ 9) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \end{document}