From: Maciej Pilichowski on 5 May 2010 09:33 Hello, I am reading "Probability and Computing" by M.Mitzenmacher and E.Upfal [1]. I am having problems understanding how the probability of comparison of two elements is calculated. Input: the sorted list (y1,y2,...,yN) of numbers. We are looking for pivot element (chosen randomly). Question: what is probability that two elements yi and yj (j>i) will be compared? Answer (from book) [2]: yi and yj will be compared if either yi or yj will be selected as pivot in first draw from sequence (yi,yi+1,...,yj-1,yj). So the probablity is: 2/(j-i+1). The problem for me is the initial claim: for example, picking up yi in the first draw from the whole list will cause the comparison with yj (and vice-versa) and the probability is 2/n. So, rather the "reverse" claim is true -- none of the (yi+1,...,yj-1) elements can be selected before yi or yj, but the "pool" size is not fixed (in first draw it is N for sure, but on the second it is smaller). Could someone please explain how the authors come up with such a simplified conclusion? Regards, [1] http://rads.stackoverflow.com/amzn/click/0521835402 [2] http://books.google.com/books?id=0bAYl6d7hvkC&lpg=PP1&dq=Probability%20and%20Computing&pg=PA37#v=onepage&q&f=false page 37 -- Moja wyprzedaz wszystkiego: ksiazki, plyty, filmy. http://www.garaz.pol.pl/ From: Maciej Pilichowski on 17 May 2010 02:21 Solved: http://stackoverflow.com/questions/2750726/randomized-quicksort-probability-of-two-elements-comparison -- Moja wyprzedaz wszystkiego: ksiazki, plyty, filmy. http://www.garaz.pol.pl/