\documentclass[12pt]{article}

\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{clrscode3e}




\begin{document}

\title{Algorithms Lab 9}

\date{}
\maketitle

\vspace{-1cm}

% The in-lab problems are to be solved during the lab time.  Work with
% your team. You do not need to turn in your answers. Ask me for
% feedback.
% %on how you write your answers.

% The homework problem set is due in one week. Work with your team, but
% write your solutions individually. List the people with whom you
% discussed the problems clearly on the first page.


% \vspace{1cm}
% {\bf Grading guidelines\footnote{Based on guidelines at Williams,
%     Swarthmore, Carleton, MIT}: }
% A solution is evaluated for: 
% \begin{itemize} 
% \item  correctness (does your algorithm solve the  problem )
% \item analysis (specify space and time complexity)
% \item style (should look professional, neat, that means not messy,
%   imagine this is your first assignment at Google and you explain it
%   to your supervisor; leave space for us to write feedback)
% \item clarity  (should be easy to understand)
% \item conciseness (avoid unnecessary explanations)
% \end{itemize} 


% On a 1-to-10 scale: 
% \begin{itemize}
% \item {[10 points]} The solution is clear, correct, neat and concise.

% \item {[8-9 points]} The solution contains a few mistakes, but they are mostly arithmetic or of little significance to the overall argument.

% \item {[6-7 points]} The solution hits on the main points, but has at
%   least one logical gap.

% \item {[4-5 points]} The solution contains several logical mistakes, but
%   parts of it are salvageable.

% \item {[2-3 points ]} The solution is just plain wrong.

% \item {[$<$2 points]} No attempt is made at solving the problem.

% \end{itemize}



\vspace{-1cm}
\section*{ In lab}

\begin{enumerate}
\item The two-colorability problem from class handout: Is it possible
  that the vertices of a given graph be assigned one of two colors,
  such that no edge connects vertices of the same color? (Note: this
  is equivalent to the question: is $G$ bipartite?))

\item (a) Describe how to compute the longest path in a DAG starting
  from a specified vertex.  (b) Describe how to compute the longest
  path in a DAG.

\item (CLRS 22.5-5) Give a linear time algorithm to compute the
  component graph of a directed graph $G=(V,E)$.  Make sure there is
  at most one edges between two vertices in the comopnent graph your
  algorithm produces.

\end{enumerate}

\section*{Homework}

\begin{enumerate} 

\item (CLRS 22.4-2) Give a linear-time algorithm that takes as input a
  directed acyclic graph $G=(V,E)$ and two vertices $s$ and $t$, and
  returns the number of simple paths from $s$ to $t$ in $G$.  For
  example, the DAG in Fig. 22.8 CLRS contains exactly four simple
  paths from $p$ to $v$: $pov$, $poryv$, $posryv$ abd $psryv$.  Your
  algorithms needs to only count the simple paths, not list then.

\item (CLRS 22.4-3) Give an algorithm that determines whether or not a
  given undirected graph $G=(V,E)$ contains a cycle. Your algorithm
  should run in $O(|V|)$ time, independent of $|E|$.


\item (4.2.27 Sedgewick Wayne) Explain why the following algorithm
  does not necessarily produce a topological order: Run BFS, and label
  the vertices by increasing distance to their respective
  sources. Note: To prove that a certain algorithm does not work, it's
  sufficient to show a counter-example.

\item (4.2.31 Sedgewick Wayne) Describe a linear time algorithm for
  computing the strong component containing a given vertex $v$.  On
  the basis of that algorithm, describe a simple quadratic time
  algorithm for computing the strong components of a digraph.


\item (4.2.32 Sedgewick Wayne) (Hamiltonian paths in DAGs) Given a
  DAG, design a linear time algorithm to determine whether there is a
  directed path that visits each vertex exactly one.


\end{enumerate}


\end{document}
%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
