Question: You are given a sequence x 1 , x 2 , dots, x n of n real numbers between 0 and 1 ( inclusive )

You are given a sequence x1,x2,dots,xn of n real numbers between 0 and 1(inclusive). You want
to reorder the numbers such that the sum of the difference between each pair of adjacent elements
is less than 2. That is, you want to find a permutation y1,y2,dots,yn where
i=1n-1|yi-yi+1|2.
For example, if we have the sequence 0.9,0.2,0.8,0.1,0.3, the sum of differences is
|0.9-0.2|+|0.2-0.8|+|0.8-0.1|+|0.1-0.3|=0.6+0.6+0.7+0.3=2.2>2.
If we rearrange the numbers as 0.2,0.9,0.8,0.1,0.3, the sum is then
|0.2-0.9|+|0.9-0.8|+|0.8-0.1|+|0.1-0.3|=0.7+0.1+0.7+0.2=1.72.
Design an algorithm that finds such an order in O(n) time.
Hint: Split the interval 0,1 into n smaller ranges. The BuCKet-SorT algorithm might provide
inspiration. (Note however that BUCKET-SoRT is not a sorting algorithm!)
Rubric.
In English, describe an algorithm that rearranges the sequence such that the given sum is
less than 2.
Prove that the sequence created by your algorithm satisfies the difference requirement.
Justify that your algorithm runs in O(n) time.
Expected response length: up to one page.
Please do this question i'm so stuck
 You are given a sequence x1,x2,dots,xn of n real numbers between

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!