\documentclass[12pt,letterpaper]{article}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{upquote}
\usepackage{graphicx}
\usepackage{url}
\usepackage{tikz}
\newcommand{\eps}{\epsilon}
\newcommand{\wh}{\widehat}
\newcommand{\wt}{\widetilde}
\newcommand{\R}{\mathbb{R}}
\newcommand{\norm}[1]{\|#1\|}
\newcommand{\abs}[1]{|#1|}
\DeclareMathOperator*{\E}{\mathbb{E}}
\DeclareMathOperator{\poly}{poly}
\DeclareMathOperator*{\mean}{mean}
\DeclareMathOperator*{\median}{median}
\title{\vspace{-1.2in}Problem Set 5}
\author{CS 331}
\date{Due Wednesday, March 11}
\begin{document}
\maketitle
\vspace{-.3in}
\begin{enumerate}
\item{} Consider running \textsc{DFSAll} on the following graph, where
every iteration (the outer one over all vertices, and the inner ones
over edges) is in alphabetical order by vertex name:
\begin{center}
\begin{tikzpicture}[every node/.style={minimum size=.3em, circle, draw=black},
arrow/.style={->, thick, shorten >= 1pt}
]
\node (11) at (1.5,4.5) {a};
\node (21) at (3,4.5) {b};
\node (31) at (4.5,4.5) {c};
\node (12) at (1.5,3) {d};
\node (22) at (3,3) {e};
\node (32) at (4.5,3) {f};
\node (13) at (1.5,1.5) {g};
\node (23) at (3,1.5) {h};
\node (33) at (4.5,1.5) {i};
\draw[arrow] (12) -- (11);
\draw[arrow] (11) -- (21);
\draw[arrow] (12) -- (21);
\draw[arrow] (11) -- (22);
\draw[arrow] (22) -- (13);
\draw[arrow] (13) -- (23);
\draw[arrow] (23) -- (22);
\draw[arrow] (23) -- (32);
\draw[arrow] (33) -- (32);
\draw[arrow] (32) -- (21);
\draw[arrow] (31) -- (32);
\draw[arrow] (21) -- (31);
\draw[arrow] (33) -- (22);
\end{tikzpicture}
\end{center}
\begin{enumerate}
\item What is the preorder of the vertices? What is the postorder?
\item Shade in the ``tree'' edges.
\item Circle the strongly connected components.
\item Give a topological ordering of the strong component graph.
\end{enumerate}
\item (Problem 21 of the book) Kris is a professional rock climber who
is competing in the U.S. climbing nationals. The competition
requires Kris to use as many holds on the climbing wall as possible,
using only transitions that have been explicitly allowed by the
route-setter. The climbing wall has $n$ holds. Kris is given a list
of $m$ pairs $(x, y)$ of holds, each indicating that moving directly
from hold $x$ to hold $y$ is allowed; however, moving directly from $y$ to
$x$ is not allowed unless the list also includes the pair $(y,
x)$. Kris needs to figure out a sequence of allowed transitions that
uses as many holds as possible, since each new hold increases his
score by one point. The rules allow Kris to choose the first and
last hold in his climbing route. The rules also allow him to use
each hold as many times as he likes; however, only the first use of
each hold increases Kris's score.
\begin{enumerate}
\item Define the natural graph representing the input. Describe and
analyze an algorithm to solve Kris's climbing problem if you are
guaranteed that the input graph is a dag.
\item Describe and analyze an algorithm to solve Kris's climbing
problem with no restrictions on the input graph. Both of your
algorithms should output the maximum possible score that Kris can
earn.
\end{enumerate}
\end{enumerate}
\end{document}