find the dim S. Problem taken from Apostol calculas Volume $2$ page No: $13$ books
Let $P$ denote the linear space of all real polynomials of degree $\le n$, where $n$ is fixed. let $ S$ denote the set of all polynomials $f$ in $P$, satisfying the condition given below . find the  dim S.
$1.$$f$ is even.
$2.$ $f$ is odd.
My attempt : we know  that dim $P_n = n+1$
I thinks if $f$  is even then dim $S= \frac{n}{2}$
if $f$ is odd then dim $S= \frac{n+1}{2}$
Is its true ?

Case 1: $n$ is even, say $n=2k$ 
*Even $f$ will be of the type $ c+c_1x^2+c_2x^4+...c_kx^{2k}$ hence dim(S) =$k+1=n/2+1$
**Odd $f$ will be of the type $d_1x+d_3x^3+...+d_{2k-1}x^{2k-1}$, hence dim(S) =$k=n/2$
Similarly consider, case 2: $n$ is odd. 
PS: * because even $ f(x) =\frac{ f(x) +f(-x)} {2}$
** odd $f(x) =\frac{f(x) - f(-x)} {2}$
