\documentclass[10pt]{article}


\usepackage{graphicx}
\usepackage{graphicx}
\usepackage{latexsym}
\usepackage{amsfonts}
\PassOptionsToPackage{boxed,section}{algorithm}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{enumerate}
\usepackage{amsmath}
\usepackage{times}
\usepackage{url}
\usepackage{hyperref}
\hypersetup{colorlinks=true}
\usepackage{color}

\voffset=-.5in
\setlength{\textheight}{8.75in}
% \setlength{\columnsep}{2.0pc}
\setlength{\textwidth}{6.8in}
%\setlength{\footheight}{0.0in}
\setlength{\topmargin}{0.25in}
\setlength{\topmargin}{0.25in}
\setlength{\headheight}{0.0in}
\setlength{\headsep}{0.0in}
\setlength{\oddsidemargin}{-.19in}
\setlength{\parindent}{1pc}


\input{defs.tex}
\title{Advanced Analysis of Algorithms - Final}

\author{
 K. Subramani \\ LCSEE, \\
 West Virginia University, \\ Morgantown, WV \\
\mbox\{ksmani@csee.wvu.edu\}}

\begin{document}
\date{}
\maketitle
\bibliographystyle{alpha}

\section{Instructions}
\begin{enumerate}
\item You are required to turn in the exam by $10$ am.
\item You are permitted to use class notes.
\item Each question is worth $4$ points.
 \end{enumerate}

\section{Problems}
\begin{enumerate}
\item
%\begin{enumerate}
%\item Expected number of inversions in a randomly permuted array.
%\item 
The Maximum Subarray problem is defined as follows: Given an array ${\bf A}[1\,\cdot \cdot \; n]$ of $n$ integers (with at least one positive element)
find a contiguous sub-array within ${\bf A}$ which has the largest sum. 

For instance, in the array ${\bf A}$ defined by $A[1]= -2$, $A[2]= 1$, $A[3]= -3$, $A[4]= 4$,  $A[5]=-1$, $A[6]= 2$,  $A[7]=1$, $A[8]= -5$, $A[9]= 4$,
 the contiguous subarray with the largest sum is $A[4\,\cdot \cdot\, 7]$  with sum $4+(-1)+2+1=6$.
 
 Design a Divide-and-Conquer algorithm for the Maximum Subarray problem and analyze its running time.
%\end{enumerate}
\comment{
\item Let ${\bf G} = \langle V, E, {\bf c} \rangle$ denote an undirected graph with vertex set $V$, edge set $E$ and a weighting function
${\bf c}:\;E \rightarrow \mathbb{Z_{+}}$. Assume that the  weighting function ${\bf c}$  associates a {\em distinct} positive weight with  each edge in $E$.
Argue that ${\bf G}$ has a {\em unique} Minimum Spanning Tree.
 }
 
 \item  A {\em matching} in a graph ${\bf G}=\langle V, E \rangle$
 is a collection of vertex-disjoint  edges.  The size of a matching is the number of edges in the
 disjoint collection. A {\em perfect matching} is a matching of size
 $\frac{|V|}{2}$. Observe that in a perfect matching, every vertex is matched to another
  vertex.  Likewise,  a graph with an odd number of vertices cannot have a perfect matching.
  Design a {\em linear-time} algorithm to check whether ${\bf G}$ has a perfect matching,
  under the assumption that ${\bf G}$ has no cycles.
  
  
\item 
\begin{enumerate}
\item Consider the following linear program in canonical form:
\begin{eqnarray*}
& \max {\bf c \cdot x} & \\
({\bf P}): \hspace{0.5in} {\bf A \cdot x} & \le & {\bf b} \\
 {\bf x} & \ge & {\bf 0}
\end{eqnarray*}
 As discussed in class, its dual is:
 \begin{eqnarray*}
 & \min {\bf b \cdot y} & \\
 ({\bf D}): \hspace{0.5in} {\bf y\cdot A} & \ge & {\bf c} \\
 {\bf y} & \ge & {\bf 0}
 \end{eqnarray*}
 
  Let ${\bf x^{*}}$ be an optimal solution to ${\bf P}$ and let ${\bf y^{*}}$ be an optimal solution to ${\bf D}$.
  
  \smallskip
  
  Let ${\bf s^{*}} = {\bf b-A\cdot x^{*}}$ and let ${\bf t^{*}} = {\bf y^{*}\cdot A - c}$.
  
  \smallskip
  Show that ${\bf x^{*}\cdot t^{*}=0}$ and that ${\bf y^{*}\cdot s^{*}=0}$.

\item Use the above theorem to solve the following linear programming problem:
\begin{eqnarray*}
& \max 10\cdot x_1+6\cdot x_2-4\cdot x_3+x_4 +12 \cdot x_5 & \\
  2\cdot x_1   +   x_2+x_3+3 \cdot x_5 & \le   18 &   \\
  x_1  +  x_2-x_3+x_4+2 \cdot x_5  & \le   6 &    \\
 &  x_1,x_2,x_3,x_4, x_5 \ge  0 & 
\end{eqnarray*}
\end{enumerate}

\item 
\begin{enumerate}
\item Let $A$ be an {\bf NP-complete} set and let $B$ be a set in {\bf P}. Assume that the $A \cap B = \emptyset$.
What is the complexity of the set $A \cup B$? If $A \cap B \not = \emptyset$, what can you
say about the complexity of $A \cup B$?
\item Let $A$ and $B$ be two languages (sets) in ${\bf NP}$. Establish that the languages (sets)
 $A \cup B$, $A \cap B$ and $A^*$ are also in {\bf NP}.
 \end{enumerate}
 
\item 

 The Minimal SAT problem is defined as follows: Given a 3CNF formula $\phi$, defined over the variables
$\{x_{1},x_{2},\ldots,x_{n}\}$ and the clauses $C_{1}$, $C_{2}$, $\ldots$, $C_{m}$, is there a satisfying assignment
for $\phi$, such that exactly one literal in each clause is set to {\bf true}? Prove that the Minimal SAT problem is {\bf NP-complete}. ({\em Hint: 3SAT or 4SAT.})





\end{enumerate}
\bibliography{classrefs}
\end{document}
