I assume that $p(x)$ and $q(x)$ are both real polynomials.
If I let $q(x)=c$, (a constant) then $p(q(x)) = p(c) = q(p(x)) = c\ \forall c$. So $p(x)=x\ \forall x$.
Is this operation valid and how to solve this problem in general?
I assume that $p(x)$ and $q(x)$ are both real polynomials.
If I let $q(x)=c$, (a constant) then $p(q(x)) = p(c) = q(p(x)) = c\ \forall c$. So $p(x)=x\ \forall x$.
Is this operation valid and how to solve this problem in general?
I think your solution is good. You just have to point out that $p(x) = x$ (which is the only solution that works for all constant $q$, as you've shown) also works for any other $q$, and you're done.