handwritten notes of Subject 7 and RandSelect in Subject 7. Likewise DeSelect of Subject 7 is
also a similarly sounding DeSelect of the handwritten notes. Provide as asymptotically tight an
answer as you can.
1. What is the running time of RQS on m keys?
2. What is the worst-case running time of RQS on m keys?
3. What is the expected running time of RQS on m keys?
4. What is the running time of RQS on m sorted keys?
5. What is the running time of DeSelect on m sorted keys ?
Q2)
We have a graph where G=(V,E) with n vertices and m edges and vertices labeled 0 through
n-1.
The graph is represented with an adjacency matrix A. There is an array F of length n that
collects
information for the vertices: F[ i ] is the information collected for vertex i. The F[.] values are
distinct and in the range 1 through 2n+1.
What would the running time be for a time efficient sorting of (the elements of) array F (based on
the values of it)?
How long does this take if we use a time efficient approach?
Q3)
Professor I. M. Nuts invents the following FasterMy method.DetSelect returns an index of the
input array that contains the relevant statistic. DeSelect is as defined/described in the first
problem.
Assume DeSelect works ok for all problem sizes.
FasterMy(A,n)
FastMy(A,0,n-1);
FastMy(A,l,r);
1. if (l<r) then
2. m=DetSelect(A[ l…..r ], r-l+1, floor((r-l+2)/2));
3. swap(A[ m ],A[ r ]);
4. m=GT-Partition(A,l,r); //GT-Partition is also known as GTP
5. FastMy(A,l,m-1);
6. FastMy(A,m+1,r);
—–
Use tight asymptotic bounds for your answers.
1. What is the running time of FasterMy for a sorted sequence of length n (of n distinct
comparable keys)?
2. What is the running time of FasterMy for a reverse sorted sequence of length n (of n
distinct comparable keys)?
3. What is the running time of FasterMy on n distinct comparable keys ?
4. What does FasterMy do (absence of any discernible bugs)?
Q4) Name the (most time efficient) algorithm to sort the keys as shown below. In case of a
tie, tie-breaker is the in-place algorithm that wins. (And CountSort beats RadixSort as well.) You
may assume Ign is an integer if that help (or take the floor otherwise, but this will give you
headaches and wont change much).
1. You are given n integer keys in the range 0 .. n**3 -1.
2. You are given n integer keys in the range n**3.. 0.. 2*n**6.
3. You are given n integer keys in the range 0 .. ((2*n)* *Ig(n))-1.
4. You are given 5*n* lg(n) integer keys in the range 0 .. 5*n -1.
5. You are given n integer keys in the range 0 .. (5*n*n*lg(n)) -1.
Q5) Same problem as before but right now give the minimal number of rounds of CountSort if
you think the answer is/was RadixSort. Use NA (Not Applicable) otherwise. If the answer is/was
CountSort this is equivalent to RadixSort with ONE round of CountSort and you pick ONE i.e. 1
as a choice, not NA.
1. You are given n integer keys in the range 0 .. n**3 -1.
2. You are given n integer keys in the range n**3.. 0.. 2*n**6.
3. You are given n integer keys in the range 0 .. ((2*n)* *Ig(n))-1.
4. You are given 5*n* lg(n) integer keys in the range 0 .. 5*n -1.
5. You are given n integer keys in the range 0 .. (5*n*n*lg(n)) -1.
Q6)
True or False
1.) Elementary school multiplication of two n-bit integers takes time O(n*n)?
2.) Elementary school multiplication of (positive) integers a and b, takes time O(a*b).
3.) I have 4 coins A, B,C,D. One is fake the other three are genuine and of the same weight. We
do not know if the fake coin is lighter or heavier. There is a scales for weighing any number of
coins on one side with any number on other side. Can you identify the fake coin with just 2
weighings in the worst case? TRUE means YES, FALSE means NO.
4.) In RadixSort we replace CountSort with InsertionSort. Will it still sort? TRUE means YES,
FALSE means NO.
5.) For RadixSort with InsertionSort above what would the running time be if we have n keys in
the range O…. k**d-1?
6.) In the synchronous page rank computation we use the adjacency matrix representation $A$
for a graph $G=(V,E)$. The page ranks of the vertex-web-pages of $G$ will be computed. Let
$G$ has $n$ vertices and $m>n$ edges and $m=o(n**2)$. Assume we have enough spare
memory i.e. memory is not an issue. Let us run page rank-for t=n iterations? What would the
running time of the synchronous page rank computation be?
Q7)