(i) How many ways can have have A in front of B?
If A is at the very front, i.e.
A B . . . .
A . B . . .
et cetera, we have 5 ways.
If A is at the second spot, we have 4 ways of placing B behind A.
If A is at the third spot, we have 3. If A is at the fourth spot, we have 2. If A is at the fifth spot, we just have one.
So adding those numbers together, just considering the position of B relative to A, we have 1+2+3+4+5=15 ways.
Then we have to consider arranging the others.
So in answering this question, the total number of ways should be 15.4!=360, where 4! represents the number of ways we can arrange the other 4 students.
(ii) In this scenario, there is always, and only a girl between A and B.
If A or B is at the front of the line,
A G B . . . or B G A . . .
- The last 3 spots are taken by two girls and a boy. To find the number of ways we can rearrange the last 3 spots, we would take it to be 3!/2!=3, as we consider the two girls to be identical, for the moment. (This is because we are strictly considering the students by only their gender for now.)
- Then consider that we have 3 girls in total, so they may switch interchangeably in their positions, and we have 3! ways of doing that.
- Finally, A and B can switch, so we have to have 2!.
So for this specific arrangement where we start the line with A G B or B G A, we have 3.3!.2! number of arrangements.
Now we can also have the cases where
. A G B . . or . B G A . .
. . A G B . or . . B G A .
. . . A G B or . . . B G A
And the method for finding the number of arrangements for each of those 3 cases is identical to how we found the number of arrangements in the case where
A G B . . . or B G A . . .
Thus we multiply our previous number by 4.
Therefore, our solution is 4.3.3!.2! = 144 number unique of arrangements.
Now I'm not particularly good at permutations and combinations, so I think a second opinion on this from another user more skilled than I at combinatorics would be great!