Write a function to implement meansort the partition


Problem

A different approach to the selection of pivot is to take the mean (average) of meansort all the keys in the list as the pivot. The resulting algorithm is called meansort.

(a) Write a function to implement meansort. The partition function must be modified, since the mean of the keys is not necessarily one of the keys in the list. On the first pass, the pivot can be chosen any way you wish. As the keys are then partitioned, running sums and counts are kept for the two sublists, and thereby the means (which will be the new pivots) of the sublists can be calculated without making any extra passes through the list.

(b) In meansort, the relative sizes of the keys determine how nearly equal the sublists will be after partitioning; the initial order of the keys is of no importance, except for counting the number of swaps that will take place. How bad can the worst case for meansort be in terms of the relative sizes of the two sublists? Find a set of n integers that will produce the worst case for meansort.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a function to implement meansort the partition
Reference No:- TGS02643155

Expected delivery within 24 Hours