Answered step by step
Verified Expert Solution
Question
1 Approved Answer
problem [ Selecting a nut - bolt pair in space ] { 2 + 3 + 1 0 } You are an astronaut in
problemSelecting a nutbolt pair in space
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 nutbolt 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 liftoff 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 match between
the nuts and bolts.
The spaceship manual says that you need the particular nutbolt 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 emphit 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 $textscmatchxy$ which
returns one of these three outputs itextscNutTooLargeii
textscNutTooSmall or iiitextscExactMatch 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
nutbolt pair in the sorted order of matched nutbolt pairs.
beginenumerate
item Describe precisely what your algorithm is given as input and what it
needs to output.
item Design an $On$ time deterministic algorithm for the problem.
Assume that any call to $textscmatch$ takes unit time. Describe
your algorithm in pseudocode, and analyze its running time.
item We now consider a randomized expected $On$ time algorithm for the
same problem!
beginenumeratelabelroman
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 nutbolt 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$
item If each of the two sets too small and too large is of size
at least $n$ let us call it a emphsuccess 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 emphnuts and bolts into three partsa matching
nutbolt 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started