What is the general approach to solving this recurrent equation given that $p(x)$ and $q(x)$ are not constant and do not depend on $n$ and $p(x)+q(x) \neq 1$. Please just give me some hints, don't solve it for me. I know this is similar to Binomial probability of $x$ successes in $n$ trials with a changing probability of success and solved using generating functions or z-transforms.
$p(x)$ can be seen as a probability of success after $n-1$ trials and $x-1$ successes and $q(x)$ as a probability of failure after $n-1$ trials and $x$ successes.