Question: cyclic rotation with absolute diffrence of two arrays Example For nuxi = [ 1 , 4 , 2 , 1 2 ] and the output

cyclic rotation with absolute diffrence of two arrays
Example
For
nuxi =[1,4,2,12] and
the output should be
solution(mus-1, nusin)=
[7,13,25,25].
.
Let's consider all possible cyclic t-shifts of
numis1
The 0-shift is 1,4,2,11, and the sum of absolute differences with
nums 2=[10,1,8,4]
=|1-10|+|4-1|+|2-8|+|11-4|=9+3+6+7=25.
The 1-shift is 11,1,4,2, and the sum of absolute differences with nums 2=[10,1,8,4] :
=|11-10|+|1-1|+|4-8|+|2-4|=1+0+4+2=7
The 2-shift is 2,11,1,4, and the sum of absolute differences with nums 2=[10,1,8,4] :
=|2-10|+|11-1|+|1-8|+|4-4|=8+10+7+0=25
The 3-shift is 4,2,11,1, and the sum of absolute differences with nums 2=[10,1,8,4] :
=|4-10|+|2-1|+|11-8|+|1-4|=6+1+3+3=13.
The non-descending list of all the sums is 7,13,25,25, which is the answer.
cyclic rotation with absolute diffrence of two

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 Finance Questions!