\documentclass[11pt]{article}

\input {preamble}

%\usepackage{psfig}

%\newcommand{\ifig}[1]{\begin{center}\psfig{file=#1.eps,height=2.0in,angle=0}\end{center}}

\begin{document}


\title{CS 591 Randomized Algorithms, HW2}

\author {Prof. Jared Saia, University of New Mexico}

\date{\emph{Due: October 7th.\\ Note: Some of this homework
is adapted from an assignment by Avrim Blum in his 1997 Fall Semester
Randomized Algorithms class}}

\maketitle

\noindent 

Consider a social network like Friendster or Orkut.  Each node in such
a network represents a person and there is a link from node $x$ to
node $y$ if $y$ is a friend of $x$.  One thing we might want to do in
such a network is, for any node $x$, get the size of the set of people
that $x$ can reach through ``friendship'' links.  In this assignment,
we'll work on the following abstract version of this problem.  We're
given a directed graph $G$, and we want to be able to quickly estimate
the size of the set of vertices reachable from each vertex $v$ in $G$.
The best exact algorithms for this problem take time
$O(\min{(mn,n^{2.38})})$ (where $m$ is the number of edges and $n$ is
the number of nodes in $G$).  In this homework, we'll get a randomized
approximation algorithm for this problem which is much faster.

The algorithm is given below ($C$ is a fixed constant parameter which
is described in problem 2.).  For any vertex $v$, let $r(v)$ be the
number of vertices $v$ can reach.

\begin{enumerate}
\item We assign to each node in the network $C\ln n$ \emph{id's}.
Each id is a random real number chosen independently from the interval
$[0,1]$.
\item For each vertex $v$ in $G$, we find the $C\ln n$ smallest IDs
among all nodes reachable from $v$.
\item For each vertex $v$, let  $\hat{m_{v}}$ be the largest of these
$C \ln n$ smallest IDs reachable from $v$.
\item If $v$ has no out edges return $1$ as our estimate of $r(v)$.
Else return $1/\hat{m_{v}}$ as our estimate of $r(v)$.
\end{enumerate}

\noindent 
{\large {\bf Problems:}}

\begin{enumerate}

\item Give a deterministic $O(m\log n +n\log^{2} n)$ time algorithm
for performing step $2$ of the algorithm.

\item Prove that for any fixed $\epsilon >0$, we can choose $C$
depending only on $\epsilon$ so that with probability at least
$1-1/n$, for all nodes $v$: 

\[
(1-\epsilon)r(v) \leq 1/\hat{m_{v}} \leq (1+\epsilon)r(v)
\]

(hint: For a fixed vertex $v$, consider the interval
$[0,\frac{1}{(1-\epsilon)r(v)}]$.  How many IDs do we expect to fall
in that interval?  How about in the interval
$[0,\frac{1}{(1+\epsilon)r(v)}]$?)

\item Extra Credit: Consider the dynamic version of this problem.
Three basic operations can occur: 1) an edge can be added to $G$
(possible with a new node as the sink of the edge), 2) an edge can be
deleted from $G$, and 3) a query can be issued for an estimate of
$r(v)$ for any node $v$.  Describe an algorithm which can handle all
of these operations efficiently.  In particular, your algorithm should
be able to handle reachability queries in time better than $O(m\log n
+n\log^{2} n)$.  To achieve this, you will obviously need
to spend more than constant time on operations 1) and 2).  \\
Challenge: Can you ensure that all three operations take expected time
$o(m)$?

\item Problem 4.1
\item Problem 4.8
\item Problem 4.12
\item Problem 4.13 

\end{enumerate}

\end{document}

% \item Bonus Question (MR 3.4):

% Consider the following experiment that proceeds in a sequence of
% rounds. For the first round, we have n balls, which are thrown
% independently and uniformly at random into n bins. After round i, for
% $i\geq 1$, we discard every ball that fell into a bin by itself in
% round i. The remaining balls are retained for round $i + 1$, in which
% they are again thrown independently and uniformly at random into the n
% bins.

% \begin{itemize}

% \item Suppose that in some round we have $k = \alpha  n$ balls. How
% many balls should you expect to have in the next round?
% \item Assuming that everything proceeded according to expectation, prove
% that we would discard all the balls within O(loglog n) rounds.
% \item Convert the previous part into a true proof that with
% probability $1 - o(1)$, we discard all balls within $O(\log\log n)$
% rounds. Hint: call a round good if the number of balls retained is not
% much more than expected. What is the probability that a round is good?
% Show that with probability $1 - o(1)$, we get enough good rounds among
% the first $O(\log\log n)$ to finish.

% \end{itemize}


{\large {\bf Exercises:}}

\begin{enumerate}
\item Describe a method for using a source of $O(\log n)$ bit random
numbers to generate a random permutation of $\{1,2,\dots ,n\}$.  Your
method should use expected $O(n)$ random numbers and take expected
$O(n)$ time.  

\end{enumerate}
