762 views
1 votes
1 votes

Answer the following part:
a) Show that, under the assumption that the input is equally likely to be any of the n! permutations of these
integers, the average number of comparisons used by the bubble sort equals E(X).
b) Use Example 5 in Section 3.3 to show that E(X) ≤ n(n − 1)/2.
c) Show that the sort makes at least one comparison for every inversion of two integers in the input.
d) Let I (P ) be the random variable that equals the number of inversions in the permutation P . Show that
E(X) ≥ E(I ).
e) Let I j,k be the random variable with  j,k (P ) = 1 if ak precedes ain P and I j,k = 0 otherwise. Show that
I(P) = \sum_{k}^{} . \sum_{j<k}^{}. I_{j,k}(P)


f ) Show that E(I) = \sum_{k}^{} . \sum_{j<k}^{}. E(I_{j,k})
g) Show that E(I j,k ) = 1/2.
h) Use parts (f) and (g) to show that E(I ) = n(n − 1)/4.
i) Conclude from parts (b), (d), and (h) that the average number of comparisons used to sort n integers is \Theta n2.

Please log in or register to answer this question.

Related questions

1 votes
1 votes
1 answer
2
Sahil Gupta asked Nov 25, 2014
2,022 views
Suppose that the probability that x is in a list of n distinct integers is 2/3 and that it is equally likely that x equals any element in the list. Find the average numbe...
0 votes
0 votes
1 answer
3
radha gogia asked Aug 15, 2015
698 views
The database can be configured to do ordered indexing on Ap or hashing on Ap. Which of the following statements is TRUE?(A) Ordered indexing will always outperform hashin...