diff --git a/chapterBalancedSearchTree.tex b/chapterBalancedSearchTree.tex index a314b9f..8fefb81 100644 --- a/chapterBalancedSearchTree.tex +++ b/chapterBalancedSearchTree.tex @@ -101,3 +101,4 @@ \section{B-Tree} \end{figure} \section{AVL Tree} +TODO diff --git a/chapterDynamicProgramming.tex b/chapterDynamicProgramming.tex index dcccd3a..ffae9a1 100644 --- a/chapterDynamicProgramming.tex +++ b/chapterDynamicProgramming.tex @@ -11,7 +11,7 @@ \section{Introduction} The so called concept dp as memoization of recursion does not grasp the core philosophy of dp. -The formula in the following section are unimportant. What is important is the definition of dp array and transition function derivation. +The formula in the following section are unimportant. Instead, what is important is the definition of dp array and transition function derivation. \subsection{Common practice} \rih{Dummy.} Use dummies to avoid using if-else conditional branch. \begin{enumerate} diff --git a/chapterGraph.tex b/chapterGraph.tex index 88a3580..9b8c9f3 100644 --- a/chapterGraph.tex +++ b/chapterGraph.tex @@ -97,6 +97,7 @@ \subsection{Undirected Graph} visited.add(k) return True \end{python} + \section{Topological Sorting} For a graph $G=\{V, E\}$, $ A \rightarrow B $, then $A$ is before $B$ in the ordered list. \subsection{Algorithm} diff --git a/chapterGreedy.tex b/chapterGreedy.tex index 0183893..99c4812 100644 --- a/chapterGreedy.tex +++ b/chapterGreedy.tex @@ -6,5 +6,5 @@ \section{Introduction} \subsection{Summarizing properties} - +TODO diff --git a/chapterSearch.tex b/chapterSearch.tex index 7b97ee0..0265301 100644 --- a/chapterSearch.tex +++ b/chapterSearch.tex @@ -1,8 +1,5 @@ \chapter{Search} - -\section{Introduction} - \section{Binary Search} Variants: \begin{enumerate} diff --git a/chapterSort.tex b/chapterSort.tex index 64eddd1..c8054eb 100644 --- a/chapterSort.tex +++ b/chapterSort.tex @@ -109,7 +109,7 @@ \subsubsection{3-way pivoting} return lt+1, gt \end{python} -\section{Stability} +\subsection{Stability} Definition: a stable sort preserves the \textbf{relative order of items with equal keys} (scenario: sorted by time then sorted by location). Algorithms: @@ -135,7 +135,7 @@ \section{Stability} \label{fig:trie} \end{figure} -\section{Applications} +\subsection{Applications} \begin{enumerate} \item Sort \item Partial quick sort (selection), k-th largest elements @@ -145,12 +145,44 @@ \section{Applications} \item Data compression \end{enumerate} +\subsection{Considerations} +\begin{enumerate} +\item Stable? +\item Distinct keys? +\item Need guaranteed performance? +\item Linked list or arrays? +\item Caching system? (reference to neighboring cells in the array? +\item Usually randomly ordered array? +(or partially sorted?)\item Parallel? +\item Deterministic? +\item Multiple key types? +\end{enumerate} + +$O(N\lg N)$ is the lower bound of comparison-based sorting; but for other +contexts, we may not need $O(N \lg N)$: +\begin{enumerate} +\item Partially-ordered arrays: insertion sort to achieve $O(N)$. \textbf{Number of inversions}: 1 inversion $=$ 1 pair of keys that are out +of order. +\item Duplicate keys +\item Digital properties of keys: radix sort to achieve $O(N)$. +\end{enumerate} + +\subsection{Summary} +\begin{figure}[hbtp] +\centering +\subfloat{\includegraphics[scale=0.80]{sort_summary}} +\caption{Sort summary} +\label{fig:trie} +\end{figure} + \section{Reversion} If $a_i > a_j$ but $i