Solution:
We will denote the people by A,B,C,… and their initial balls by the corresponding small letters. Thus the initial state is Aa,Bb,Cc,Dd,Ee(,Ff). A swap is denoted by the (capital) letters of the people involved.
a) Five people form 10 pairs, so at least 10 swaps are necessary.
In fact, 10 swaps are sufficient:
Swap AB, then BC, then CA; the state is now Aa,Bc,Cb,Dd,Ee.
Swap AD, then DE, then EA; the state is now Aa,Bc,Cb,De,Ed.
Swap BE, then CD; the state is now Aa,Bd,Ce,Db,Ec.
Swap BD, then CE; the state is now Aa,Bb,Cc,Dd,Ee.
All requirements are fulfilled now, so the answer is 10.
b) Six people form 15 pairs, so at least 15 swaps are necessary. We will prove that the final number of swaps must be even. Call a pair formed by a ball and a person inverted if letter of the ball lies after letter of the person in the alphabet. Let T be the number of inverted pairs; at the start we have T=0. Each swap changes T by 1, so it changes the parity of T. Since in the end T=0, the total number of swaps must be even. Hence, at least 16 swaps are necessary. In fact 16 swaps are sufficient:
Swap AB, then BC, then CA; the state is now Aa,Bc,Cb,Dd,Ee,Ff.
Swap AD, then DE, then EA; the state is now Aa,Bc,Cb,De,Ed,Ff.
Swap FB, then BE, then EF; the state is now Aa,Bd,Cb,De,Ec,Ff.
Swap FC, then CD, then DF; the state is now Aa,Bd,Ce,Db,Ec,Ff.
Swap BD, then CE, then twice AF, the state is now Aa,Bb,Cc,Dd,Ee,Ff.
All requirements are fulfilled now, so the answer is 16.