Skip to content

Commit

Permalink
init greedy
Browse files Browse the repository at this point in the history
  • Loading branch information
idf committed Nov 1, 2015
1 parent fe07c4e commit a8b5f00
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
5 changes: 3 additions & 2 deletions chapterDynamicProgramming.tex
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ \section{Sequence}\label{dpSequence}
\end{array} \right.
\end{eqnarray*}
\runinhead{Maximal product subarray.} Find the $A$'s subarray within an array which has the largest product.
\runinhead{Maximal product subarray.} Find the subarray within an array $A$ which has the largest product.
\begin{itemize}
\item Let $small_i$ be the smallest product end with $A_i$.
\item Let $large_i$ be the largest product end with $A_i$.
\item The states can be negative.
\end{itemize}
\begin{eqnarray*}
&& small_i = \min\big( A_i,\ small_{i-1}\cdot A_i,\ large_{i-1}\cdot A_i \big)
Expand Down Expand Up @@ -248,7 +249,7 @@ \section{Backpack}
F_{i, c}= \max\big(&&F_{i-1, c}, \\
&&F_{i-1, c-w_i}+v_i\big)
\end{eqnarray*}
TODO advanced backpack problem.
Advanced backpack problem\footnote{\href{http://github.com/tianyicui/pack}{Nine Lectures in Backpack Problem}.}.
\section{Local and Global Extremes}
\subsection{Long and short stocks}
Expand Down
9 changes: 2 additions & 7 deletions chapterGreedy.tex
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
\chapter{Greedy}


\section{Introduction}
TODO
\begin{python}
---
ABC
___
\end{python}
Philosophy: choose the best options at the current state without reverting the choice in the future.

A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding a global optimum.
2 changes: 1 addition & 1 deletion chapterSort.tex
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ \subsection{Stability}
\textbf{Long-distance swap} operation is the key to find the unstable case during sorting.
\begin{figure}[hbtp]
\centering
\subfloat{\includegraphics[scale=.60]{stable_sort}}
\subfloat{\includegraphics[scale=.50]{stable_sort}}
\caption{Stale sort vs. unstable sort}
\label{fig:trie}
\end{figure}
Expand Down

0 comments on commit a8b5f00

Please sign in to comment.