A particle $P$, of mass $m$, is attached to one end of a light inextensible string of length $a$. The other end of the string is attached to a fixed point $O$. The particle $P$ moves in complete vertical circles about $O$ with the string taut. The points $A$ and $B$ are on the path of $P$, with $AB$ a diameter of the circle. $OA$ makes an angle $\theta$ with the downward vertical through $O$, and $OB$ makes an angle $\theta$ with the upward vertical through $O$. The speed of $P$ when it is at $A$ is $\sqrt{5ag}$.
The ratio of the tension in the string when $P$ is at $A$ to the tension in the string when $P$ is at $B$ is $9:5$.
(a) Find the value of $\cos\theta$. [6]
(b) Find, in terms of $a$ and $g$, the greatest speed of $P$ during its motion. [2]