Step-by-step explanation:
Let the other 4 friends arrange themselves first. There are 4! ways to do so.
Now there are 3 spaces between the 4 friends, and 1 at each end (total 5 spaces)
Example: _F_F_F_F_
Alice can choose to stand in any of the 5 spaces. David can choose to stand in any of the 4 remaining spaces (now Alice and David are not next to each other)
Total number of ways = 4! * 5 * 4 = 480.