Dwarf height problem


This question comes from the 2001 British Maths Olympiad second round competition.
By Peter Conlon (P2714) on Wednesday, February 28, 2001 - 06:36 pm :

N dwarfs of heights 1,2,3...,N are arranged in a circle. For each pair of neighbouring dwarfs the positive difference between their heights is calculated; the sum of these N differences is called the "total variation" V of the arrangement. Find (with proof) the maximum and minimum possible values of V.

Peter


By Michael Doré (Md285) on Wednesday, February 28, 2001 - 11:04 pm :

Part of this is easy. Suppose the numbers 1,2,...,n-1 are arranged on a circle (in that order). Consider the effect on the total variation of inserting n between a,b (where b> a and a,b are consecutive in the circle of 1,2,...,n-1).

The change in total variation is:

(n - a) + (n - b) - (b - a) = 2n - 2b = 2(n - b) > = 2

This means that the total variation must go up by at least two each time n increases by 1. When n = 2 the total variation is 2, so in general the total variation > = 2n - 2. Clearly this inequality is an equality in the case where the numbers appear in the order:

1,2,...,n

Therefore the minimal total variation is trivially 2n - 2. Finding the maximal will be rather more tricky I suspect.


By Michael Doré (Md285) on Wednesday, February 28, 2001 - 11:34 pm :

OK, I think you can answer the maximal part by considering the circle with the numbers p,p+1,...,q then finding where the numbers p-1,q+1 should be placed to cause the maximal increase in the total variation. I'll investigate more thoroughly in the morning.


By James Lingard (Jchl2) on Thursday, March 1, 2001 - 01:13 am :

That the minimal total variation is 2n - 2 is obvious if you think about it for a moment: if you go once round the circle, starting at 1, then as you go round you have to get all the way up to n at some point and then all the way back down to 1.

The minimum is achieved whenever you go 'directly' up to n and 'directly' back down again, so when the numbers are arranged

1, a1 , a2 , ..., ar , n, b1 , b2 , ..., bs ,

where a1 < a2 < ... < ar and b1 > b2 > ... bs .

For the maximal part, following on along the suggested line of thinking, I get that the maximum is

(1/2)(n - 1)(n + 1) if n is odd

or

(1/2)(n2 ) if n is even

though I haven't got time to post the solution now - I will do tomorrow if no-one beats me to it (or points out that this isn't correct!).

James.


By Michael Doré (Md285) on Thursday, March 1, 2001 - 02:14 pm :

I agree with James' answers. The solution to the first part is nice and intuitive; for some reason I didn't think of it that way! Still it's easy to arrive at 2n - 2 even if you don't think of that.

For the second part, I have a slightly different way of doing it than the way I suggested at 11:34 yesterday. Suppose the numbers are arranged (going round the circle) in the order b1 , b2 , ..., bn . Then the total difference will be:

e1 (b2 - b1 ) + e2 (b3 - b2 ) + ... + en-1 (bn - bn-1 ) + en (b1 - bn )

where e1 ,...,en are each +1 or -1.

This can then be re-arranged as:

b1 (-e1 + en )
+ b2 (-e2 + e1 )
+ b3 (-e3 + e2 )
+ ...
+ bn (-en + en-1 )

Letting q1 = -e1 + en , q2 = -e2 + e1 , q3 = -e3 + e2 , ..., qn = -en + en-1 we see that the total variation is:

q1 b1 + q2 b2 + ... + qn bn

where each qi is one of -2,0,2. Furthermore q1 + ... + qn = 0, so the number of qi s which are -2 is the same as the number which are +2.

Then supposing we want to maximise:

y = q1 b1 + q2 b2 + ... + qn bn

only on the constraint that each qi is one of -2,0,2 and the number of -2s is the same as the number of +2s. Without loss of generality we can set bi = i and then in that case we see immediately that the sequence qi is increasing (otherwise, if qj < qi with i < j, swap around qi , qj and we get a larger value of y).

Moreover, no more than 1 of the qi s can be zero. If qi = qj = 0 (with i < j), then we would be able to increase y by changing qi to -2 and qj to +2 (keeping the others fixed).

If n is even then we cannot have exactly one of the qi s zero, and if n is odd we cannot have none of the qi s 0. Therefore, to maximise y the sequence qi must be:

-2,-2,...,-2,0,2,2,...,2 (n odd)
-2,-2,...,-2,2,...,2 (n even)

where of course there are equally many -2s as +2s in either case.

Therefore the maximal total variation cannot possibly be more than:

2((n/2+1) + (n/2+2) + ... + n) - 2(1 + 2 + ... + n/2)
= n(n+1) - n/2(n/2+1) - n/2(n/2+1)
= n2 /2

when n is even and

2((n+3)/2 + (n+5)/2 + ... + n) + 0((n+1)/2) - 2(1 + 2 + ... + (n-1)/2) = 2(n(n+1)/2 - (n+1)(n+3)/8 - (n-1)(n+1)/8) = (n-1)(n+1)/2

when n is odd. Can we get equality? Yes, easily in both cases:

n Even: arrange them as 1,n,2,n-1,3,n-2,...,n/2,(n+2)/2

n Odd: arrange them as 1,n,2,n-1,...,(n-1)/2,(n+1)/2

Therefore the maximal total variation is n2 /2 (n even) and (n-1)(n+1)/2 with n odd. The minimal total variation is 2n-2.