Solutions of Theory of Algorithms assignment 7-5

Solutions of Theory of Algorithms assignment 7-5 - n/2 =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Solutions of Theory of Algorithms Assignment 4 Exercise 7-5 a. As in this variation there exists three elements to take their median, therefore there are six different permutations for them. For each element, it could be greater than, smaller than, or equal to i. Therefore, p i =6*Pr[x<i]*Pr[x>i]*Pr[x=i] =6*(n/2)*(n-i/(n-2))*(1/(n-1)) b. The probability in the original randomized algorithm is 1/n The probability in this variation (using the previous eq.) is p
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n/2 = 6*(n/2)*((n-n/2)/(n-2))*(1/(n-1)) The ratio between the two probabilities is 1/n * 6 *(n/ 2 )*((n-n/2)/(n-2 ))*(1/(n-1 )) If n goes to infinity, their limiting ratio will be 2/3 c. This variation just tries to enhance the way of choosing the pivot, if it succeeds to get balanced partition in each iteration (best case), it will take running time of (n lg n). so, it can only affect the constant factor and not the whole running time....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online