Solved: In this exercise we derive an estimate of the

Chapter 6, Problem 6.4.35

(choose chapter or problem)

In this exercise we derive an estimate of the average-case complexity of the variant of the bubble sort algorithm that terminates once a pass has been made with no interchanges. Let X be the random variable on the set of permutations of a set of n distinct integers {a" az, ... , an} with a, < az < ... < an such that X(P) equals the number of comparisons used by the bubble sort to put these integers into increasing order. a) Show that, under the assumption that the input is equally likely to be any of the n! permutations ofthese 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) :s 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 Ij,k be the random variable with Ij,k(P) = 1 if ak precedes aj in P and Ij,k = 0 otherwise. Show that I(P) = Lk Lj i) Conclude from parts (a), (b), and (h) that the average number of comparisons used to sort n integers is B(nz ).

Unfortunately, we don't have that question answered yet. But you can get it answered in just 5 hours by Logging in or Becoming a subscriber.

Becoming a subscriber
Or look for another answer

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back