Skip to content

Commit

Permalink
💄 use latex min and max
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketgargya committed Nov 28, 2021
1 parent 22f9277 commit f11bb6a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/lecture13/lecture13.tex
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ \subsection{Longest Increasing Subsequence}
\item \textit{Recursive Relation}:
\begin{itemize}
\item $LIS(i, j) = LIS(i - 1, j)$ for $A[i] > A[j]$
\item $LIS(i, j) = max(LIS(i - 1, j), 1 + LIS(i - 1, i))$ for $A[i] \leq A[j]$
\item $LIS(i, j) = \max(LIS(i - 1, j), 1 + LIS(i - 1, i))$ for $A[i] \leq A[j]$
\end{itemize}
\end{itemize}
\item[] \includegraphics[width=\textwidth]{lecture13/images/lis-memo.png}
Expand Down
4 changes: 2 additions & 2 deletions src/lecture14/lecture14.tex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ \subsection{Recursive Equation}
\item \texttt{ISLk(n + 1, 0)} $= 1$ if $\exists i < j \leq n + 1$ such that \texttt{ISLk(j, h - 1)} $= 1$ and \texttt{IsStringInL(A[i...(j - 1)])} $= 1$.
\item \texttt{ISLk(i, h)} $= 0$ otherwise.
\end{itemize}
\item \texttt{ISLk(i, h)} $= max_{i < j \leq n + 1}\texttt{ISLk(j, h - 1) }\times$ \texttt{IsStringInL(A[i...(j - 1)])} alternatively.
\item \texttt{ISLk(i, h)} $= \max_{i < j \leq n + 1}\texttt{ISLk(j, h - 1) }\times$ \texttt{IsStringInL(A[i...(j - 1)])} alternatively.
\end{itemize}

\subsection{Iterative Algorithm}
Expand Down Expand Up @@ -130,7 +130,7 @@ \subsubsection{Algorithm}
\item Let \texttt{Opt($i$, $j$)} be the optimal cost of aligning $x_1...x_i$ and $y_1...y_j$.
\begin{equation}
\texttt{Opt}(i, j) = \begin{cases}
\texttt{min} \left\{
\min \left\{
\begin{tabular}{c}
$\alpha_{x_iy_j} + \texttt{Opt}(i - 1, j - 1)$ \\
$\delta + \texttt{Opt}(i - 1, j)$ \\
Expand Down
2 changes: 1 addition & 1 deletion src/lecture15/lecture15.tex
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ \subsection{Maximum Weight Independent Set Problem}
\item $T(u)$: a subtree of $T$ hanging at node $u$.
\item $OPT(u)$: the max weighted independent set value in $T(u)$.
\begin{equation}
OPT(u) = max \left\{
OPT(u) = \max \left\{
\begin{tabular}{c}
$\sum_{\text{$v$ child of $u$}} OPT(v)$ \\
$w(u) + \sum_{\text{$v$ grandchild of $u$}} OPT(v)$
Expand Down
6 changes: 3 additions & 3 deletions src/lecture18/lecture18.tex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ \subsection{Single Source Shortest Paths}
\item \textit{Special case}: $l(e)$ is an integer for all $e$.
\begin{itemize}
\item We can reduce the graph to unit edge length p
\item Let $L = max_e l(e)$. The new graph has $O(mL)$ edges and $O(mL + n)$ nodes. BFS would take $O(mL + n)$ time. This is not efficient if $L$ is large enough.
\item Let $L = \max_e l(e)$. The new graph has $O(mL)$ edges and $O(mL + n)$ nodes. BFS would take $O(mL + n)$ time. This is not efficient if $L$ is large enough.
\end{itemize}
\item BFS works because \texttt{BFS(s)} explores nodes in increasing distance from $s$.
\begin{itemize}
Expand All @@ -92,13 +92,13 @@ \subsection{Finding the $i$th Closest Node}
\item For each $u \in V - X$, we can observe that
\begin{itemize}
\item $dist(s, u) \leq d'(s, u)$ since we are constraining the paths by only usings nodes in $X$ in $d'$.
\item $d'(s, u) = min_{t \in x}(dist(s, t) + l(t, u))$
\item $d'(s, u) = \min_{t \in x}(dist(s, t) + l(t, u))$
\end{itemize}
\item If $v$ is the $i$th closest node to $s$, then $d'(s, v) = dist(s, v)$.
\begin{itemize}
\item Let $v$ be the $i$th closest node to $s$. Then there is a shortest path $P$ from $s$ to $v$ that contains only nodes in $X$ as intermediate nodes. Therefore $d'(s, v) = dist(s, v)$.
\end{itemize}
\item The $i$th closest node to $s$ is the node $v \in V - X$ such that $d'(s, v) = min_{u \in V - X}d'(s, u)$.
\item The $i$th closest node to $s$ is the node $v \in V - X$ such that $d'(s, v) = \min_{u \in V - X}d'(s, u)$.
\begin{itemize}
\item For every node $u \in V - X$, $dist(s, u) \leq d'(s, u)$ and for the $i$th closest node $v$, $dist(s, v) = d'(s, v)$. Moreover, $dist(s, u) \geq dist(s, v)$ for each $u \in V - X$.
\end{itemize}
Expand Down
6 changes: 3 additions & 3 deletions src/lecture19/lecture19.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ \subsection{Dijkstra's Algorithm and Negative Lengths}

\subsection{What Can We Learn from Dijkstra?}
\begin{itemize}
\item However, $d'(s, u) = min(d'(s, u), dist(s, v) + l(v, u))$ because $d'(s, u) \geq d(s, u)$, still holds true.
\item However, $d'(s, u) = \min(d'(s, u), dist(s, v) + l(v, u))$ because $d'(s, u) \geq d(s, u)$, still holds true.
\item If $s = v_0 \rightarrow v_1 \rightarrow v_2 \rightarrow ... \rightarrow v_k$ is a shortest path from $s to v_k$, then
\begin{itemize}
\item for $1 \leq i < k$, $s = v_0 \rightarrow v_1 \rightarrow v_2 \rightarrow ... \rightarrow v_i$ is a shortest path from $s$ to $v_i$. In other words, a subpath of a shortest path is still a shortest path.
Expand Down Expand Up @@ -38,9 +38,9 @@ \subsection{Hop Based Recursion: Bellman-Ford Algorithm}
\begin{itemize}
\item $d(v, k)$ is the shortest path length from $s$ to $v$ using at most $k$ edges. Note: $dist(s, v) = d(v, n - 1)$.
\item Recursion for $d(v, k)$: \begin{equation}
d(v, k) = min \left\{
d(v, k) = \min \left\{
\begin{tabular}{c}
$min_{u \in In(v)}(d(u, k - 1) + l(u, v))$ \\
$\min_{u \in In(v)}(d(u, k - 1) + l(u, v))$ \\
$d(v, k - 1)$ \\
\end{tabular}
\right\}
Expand Down
2 changes: 1 addition & 1 deletion src/lecture20/lecture20.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ \section{The Crucial Optimality Substructure}

\subsection{Shortest Distance Problems}
\begin{itemize}
\item The optimality substructure is $dist(s, u) = min_{v \in In(u)}(dist(s, v) + \ell(v, u))$.
\item The optimality substructure is $dist(s, u) = \min_{v \in In(u)}(dist(s, v) + \ell(v, u))$.
\item For Bellman-Ford, we used the formula $d(u) = \min_{v \in In(u)}(d(v) + \ell(v, u))$.
\begin{itemize}
\item If $v$ is on the shortest path of $u$ and $d(v) = dist(s, v)$, then $d(u) = dist(s, u)$ in the next iteration.
Expand Down

0 comments on commit f11bb6a

Please sign in to comment.