Question: problem [ Selecting a nut - bolt pair in space ] { 2 + 3 + 1 0 } You are an astronaut in

\problem[Selecting a nut-bolt pair in space]{2+3+10}
You are an astronaut in space given the enviable task of doing a space
walk to fix a loose shield in your spaceship. The shield is loose
since it is missing a single nut-bolt pair. You have your toolbox
with $N$ different nuts and $N$ different bolts. When these were
originally packed, they were in matching pairs and sorted, but the
violent lift-off undid all of that, and you are left with $N$ nuts of
different widths and $N$ bolts of different widths scattered all over,
only with the comfort of knowing that there exists a 1-1 match between
the nuts and bolts.
The spaceship manual says that you need the particular nut-bolt pair
of rank $k$ in the sorted order of nuts and bolts. That is, if you
were to sort both nuts and bolts in increasing order of widths, then
the $k$th nut and $k$th bolt in this order (which will match one
another) is the desired pair. But here is the catch: the difference
between the sizes of two nuts or the sizes of two bolts is so tiny
that \emph{it is impossible for you to manually compare two different
nuts or two different bolts}. You can, however, try a nut $x$ and
bolt $y$ together, using the procedure $\textsc{match}(x,y)$ which
returns one of these three outputs (i)\textsc{Nut-Too-Large},(ii)
\textsc{Nut-Too-Small}, or (iii)\textsc{Exact-Match}. But note that
there is no way to compare two nuts together, or two bolts together.
In this problem, we will develop algorithms for determining the $k$th
nut-bolt pair in the sorted order of matched nut-bolt pairs.
\begin{enumerate}
\item Describe precisely what your algorithm is given as input and what it
needs to output.
\item Design an $O(n^2)$ time deterministic algorithm for the problem.
Assume that any call to $\textsc{match}$ takes unit time. Describe
your algorithm in pseudocode, and analyze its running time.
\item We now consider a randomized expected $O(n)$ time algorithm for the
same problem!
\begin{enumerate}[label=(\roman*)]
\item Suppose you select a random nut, match all the $n$ bolts with this
nut, and partition the bolts based on the three responses: one set
of bolts that are too small, one matching nut-bolt pair, one set
of bolts that are too large. What is the probability that the
sets of bolts that are too small and too large are each of size at
least $n/4$?
\item If each of the two sets -- too small and too large -- is of size
at least $n/4$, let us call it a \emph{success}. Suppose you
repeat the step given in (i) until success. What is the expected
number of times you have to repeat the above step to achieve
success?
\item Design a randomized algorithm that uses the idea from (i), then
partitions the \emph{nuts and bolts} into three parts---a matching
nut-bolt pair, and two groups of appropriately selected nuts and
bolts with the number of nuts in each group equal to the number of
bolts in the group--- and does a suitable recursion (like
Randomized Selection) to solve the given problem. Describe your
algorithm in pseudocode.
\item Using (ii), analyze the expected running time of the problem.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!