(i) Consider the cases where the end books are both A or both B.
For both ends being A: Arrange the remaining 9 books (3 A, 2 B, 5 C) in the middle. The number of ways is given by:
\(\frac{9!}{3!2!5!} = 756\)
For both ends being B: Arrange the remaining 9 books (4 A, 1 B, 5 C) in the middle. The number of ways is given by:
\(\frac{9!}{4!1!5!} = 126\)
Total arrangements: \(756 + 126 = 882\).
(ii) Treat all A books as a single unit. This gives us 8 units to arrange (1 A unit, 2 B, 5 C). The number of ways to arrange these units is:
\(\frac{8!}{2!5!} = 168\)
Now, consider the arrangements where B books are together. Treat B books as a single unit, giving us 7 units (1 A unit, 1 B unit, 5 C). The number of ways to arrange these units is:
\(\frac{7!}{5!} = 42\)
Subtract the cases where B books are together from the total arrangements:
\(168 - 42 = 126\)