Question

7. I want you to now remember the following partitioning problem we considered a while ago You are given a list L of length m and asked to partition the elements of Linto two sublists L1 and L2 such that (i) n/3 S L Lal S 2n/3 and (ii) all elements in L1 are less than or equal to all elements in L2 We designed a simple, randomized (Las Vegas) algorithm for this problem that ran in O(n) expected time. Let us replace the call to partition in the code for quickSort given above by a call this Las Vegas algorithm. After we obtain a partition L1,L2) by calling this Las Vegas algorithm, we can simply call quickSort on L1 and then on L2. Now we have a randomized (Las Vegas) version of quickSort. I would like to analyze the expected running time of this algorithm (a) Write down a recurrence relation for the expected running time of this randomized version of quickSort (b) Solve this recurrence to obtain an upper bound on the expected running time of this randomized version of guickSort

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a) Recurrence relation

TC)Expreted timeto sole n looneb The awerage bme Vel TCO-en) and pe c 必! 仁-|

------------------------------------------

(b) Solving the above recurrence relation:

y) The above can le Solved m ethad In the in dchive step, am ume fo a and longe buch that anlag n t >TO, we have : - v) -1 b

Add a comment
Know the answer?
Add Answer to:
I want you to now remember the following partitioning problem we considered a while ago. You...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (20 points) Recall the following deterministic select algorithm: (a) Divide the n elements into groups of...

    (20 points) Recall the following deterministic select algorithm: (a) Divide the n elements into groups of size 5. So n/5 groups. (b) Find the median of each group. (c) Find the median x of the n/5 medians by a recursive call to Select. (d) Call Partition with x as the pivot. (e) Make a recursive call to Select either on the smaller elements or larger elements (de- pending on the situation); if the pivot is the answer we are done....

  • When asked to describe an algorithm you are expected to give a clear pseudo-code description of...

    When asked to describe an algorithm you are expected to give a clear pseudo-code description of the algorithm 1. (10 pts) Here is a new sorting algorithm NewSort Suppose the original call made is NewSort(A,0,n-1) where A is an array integers. == void NewSort(int A[], int i, int j){ \\ sorts the subarray Aſi..j] if (j i+1) \\when there are only 2 elements if (A[i] > A[j]) swap(A,i,j) \\swaps A[i] and A[j] else { int k = (j-i+1)/3; NewSort(A,i,j-k); \\...

  • problem 2 can use Det-Selection(A, p, q, r) as a sub-routine (i.e, you don't need to...

    problem 2 can use Det-Selection(A, p, q, r) as a sub-routine (i.e, you don't need to write its pseudo-code). To sort an array A, you will then call Det-QuickSort(A, 1, n). You also need to provide the worst case time complexity analysis of your algorithm. 2. (20 points) Given a set of n distinct numbers, we wish to find the k largest in sorted order using a comparison-based algorithm. Give an algorithm that implements each of the following methods, and...

  • python. It is better to use "random" Now we want to analyze how often the tortoise...

    python. It is better to use "random" Now we want to analyze how often the tortoise and hare win or lose the race as we vary the race length. We can wrap the logic of our race simulation in a function and then call it many times to simulate many races. Then, we can collect some statistics to see how likely is it that the tortoise (or hare) wins a race of a given length. Specifically, write a function simulate_race...

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT