
\documentclass[12pt]{article}

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




\begin{document}

\title{Algorithms Lab 10}

\date{}
\maketitle

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

\centerline{\includegraphics[height=3cm]{graph.jpg}}

\begin{enumerate} 
\item Show how Prim's and Kruskal's algorithms run on an example graph.

  \begin{itemize} 
  \item What is the role of checking whether $v \in PQ$?
  \item How many  {\sc Insert} operations are performed by the algorithm? 
  \item How many  {\sc Delete-min} operations are performed by the algorithm? 
  \item How many  {\sc Decrease-Key} operations are performed by the algorithm? 
  \item Assuming the priority is implemented as a heap, what is the complexity of the algorithm? 
  \end{itemize} 

\item Show how Dijkstra's algorithm will run on the example graph from
  source vertex $a$.
  What will happen if you run Dijkstra's algorithm on a graph with
  negative edge weights?
\end{enumerate} 


\section*{Homework}

\begin{enumerate}

\item (CLRS 23.1-1) Show that a minimum-weight edge in $G$ belongs to
  some MST of $G$.

%  {\bf Answer: } It follows basically from the cut theorem: For any
%   cut $(V_1, V_2)$, the lightest edge that crosses the cut must be in
%   an MST. Consider a cut that places the two endpoints of the lightest
%   edge on two different sides of the cut. By the theorem, the edge
%   must be in an MST.
  
 %  \item (CLRS 24.2-4) Suppose that all edge weights in a graph are
%   integers in the range from 1 to $|V|$.  How can you take advantage
%   of this in Kruskal's algorithm, and how fast can you make it run?
%   What if the edge weights are integers from 1 to $W$ for some
%   constant $W$?

% {\bf Answer:} If we know that the edge weights are integers, we can
%   start thinking of using a more efficient sort, such as bucket-sort
%   or counting sort.  This runs in $O(n+k)$ time, where $n$ is the
%   number of inputs being sorted (in our case $|E|$) and $k$ is their
%   range (in our case $|V|$). In our case sorting the edge weights with
%   bucket-sort will take $O(V+E)$ time. 

%   In addition to the sorting Kruskal's algorithm uses a Union-Find
%   data structure, for $V$ Make-Set operations, $O(E)$ Find-Set
%   operations, and $O(V)$ Union-Set operations.  In class we talked
%   about how to store the sets as linked lists of elements pointing to
%   the first in the list, etc.  This way Make-set and Find-Set run in
%   $O(1)$ time, and Union-Set runs in amortized $O(\lg V)$
%   time. Overall this part of the algorithm will run in $O(E \lg V)$
%   time.

%  If you read the chapter in the textbook, you'll see that in fact a
%   much better bound for Union-Find operations can be obtained with a
%   very similar idea, namely $O(\alpha(V))$ amortized per operation;
%   here $\alpha(*)$ is the inverse Akermann function, and is very very
%   small, practically a constant. With this structure, Kruskal will
%   take $O(sort)$ + $O(E \alpha(V))$.  With a standard merge ($O(E \lg
%   E) = O(E \lg V)$ the sorting step will dominate.  When the edge
%   weights are integers in the range from 1 to $|V|$, sorting is
%   reduced to $O(V+E)$ and Kruskal runs in $O(E \alpha(V))$.


\item (CLRS 24.3-6) We are given a directed graph $G=(V,E)$ on which
  each edge $(u,v)$ has an associated value $r(u,v)$, which is a real
  number in the range $[0,1]$ that represents the reliability of a
  communication channel from vertex $u$ to vertex $v$. We interpret
  $r(u,v)$ as the probability tht the channel from $u$ to $v$ will not
  fail, and we assume that these probabilities are independent.  Give
  an efficient algorithm to find the most reliable path between two
  given vertices.

\item (GT C-7.7) Suppose you are given a diagram of a telephone
  network, which is a graph $G$ whose vertices represent switching
  centers, and whose edges represent communication links between the
  two centers. The edges are marked by their bandwidth. The bandwidth
  of a path is the \emph{minimum} bandwidth along the path.  Give an
  algorithm that, given two switching centers $a$ and $b$, will output
  a maximum bandwidth path between $a$ and $b$.


\item Consider a directed weighted graph with non-negative weights and V
  vertices arranged on a rectangular grid. Each vertex has an edge to its
  southern, eastern and southeastern neighbours (if existing). The
  northwest-most vertex is called the root.  The figure below shows an
  example graph with V=12 vertices and the root drawn in black:
  
  \centerline{\includegraphics[height=3cm]{graph-xv.pdf}}
 
  Assume that the graph is represented such that each vertex can access
  {\bf all} its neighbours in constant time.

  \begin{enumerate}
  \item How long would it take Dijkstra's algorithm to find the length of
    the shortest path from the root to all other vertices?
  \item Describe an algorithm that finds the length of the shortest paths
    from the root to all other vertices in $O(V)$ time.
  \item Describe an efficient algorithm for solving the
    all-pair-shortest-paths problem on the graph (it is enough to find the
    length of each shortest path).
  \end{enumerate}


\end{enumerate} 

\end{document} 
