How to solve this function $f(x)$ for degree $3$ or $4$ 
If $f(x)=0$ is a polynomial whose coefficients are either $1$ or $-1$ and whose roots are all real, then the degree of $f(x)$ can be equal to$:$


$A$. $1$


$B$. $2$


$C$. $3$


$D$. $4$

My work$:$
For linear only four polynomials are possible which are $x+1$ and $-x+1$ and $x-1$ and $-x-1$. All of which have real roots. So the answer is $A$.
For quadratic we have $8$ polynomials which are $x^2+x+1$ and $x^2+x-1$ and $x^2-x+1$ and $x^2-x-1$ and $-x^2+x+1$ and $-x^2-x+1$ and $-x^2+x-1$ and $-x^2-x-1$ Here four of the polynomials have real roots which are $x^2+x-1$ and $-x^2-x+1$ and $-x^2+x+1$ and $x^2-x-1$. So we can say that $f(x)$ can be of degree two. So $B$ is also the answer.
For cubic and quartic I don't know how to proceed. Any hints or solutions are appreciated.
 A: Let's analyze the cubic case.
Note that the general cubic equation
$$x^3+bx^2+cx+d$$ may be reduced to the so-called depressed cubic with the substitution $x = y-b/3$.  After the algebra, we get the equivalent equation
$$y^3+py+q = y^3+(c-\frac{b^2}{3})y+(\frac{2}{27}b^3-\frac{bc}{3}+d) = 0.$$
The discriminant $\Delta$ of the cubic is given by $p^3/27+q^2/4$.  This gives us
$$\Delta = \frac{b^3 d}{27} - \frac{b^2 c^2}{108} - \frac{b c d}{6} + \frac{c^3}{27} + \frac{d^2}{4}.$$
If $\Delta \leq 0$, the cubic has all three roots being real.
Notice that from the above equation, the smallest $\Delta$ can be is $0$ which occurs if $b^3d = -1,bcd = 1,c^3 = -1$.  This requires $c = -1$ and $b,d$ to have opposite signs.  This indeed is possible.
For example, $x^3-x^2-x+1 = 0$, has roots $\pm 1$ with $1$ being a double root.
A: The cubic case is handled by noting that
$(x-1)^2(x+1)=x^3-x^2-x+1=0$
has all of its roots real.
For the quartic case, we do not have such a simply soluble case. But we can use Descartes' Rule of Signs, if we are careful with it.
For instance, when we have all coefficients positive, as in $x^4+x^3+x^2+x+1=0$, four negative roots are allowed. As we will see, that particular equation does not have such roots, but $x^4+10x^3+35x^2+50x+24=0$ with the same sign pattern does (the polynomial is $(x+1)(x+2)(x+3)(x+4)$). The question, then, is how to refine the Rule of Signs so as to distinguish $x^4+x^3+x^2+x+1=0$ from $x^4+10x^3+35x^2+50x+24=0$.
We can improve the bounds from the Rule of Signs by multiplying in factors that will cause the product to have zero coefficients, which is likely to cut down on the sign changes and thus lead to fewer allowed real roots. In the problem here, the coefficients of the polynomial are $\pm1$, which suggests the factor $x+1$ or $x-1$ would likely work.
Going back to $x^4+x^3+x^2+x+1=0$, then we see that choosing $x-1$ as the auxiliary factor gives
$x^5-1=0$
with sign pattern $+0000-$. This allows only one positive root, and reversing alternating signs reveals that there are no negative ones. Thus $x^5-1=0$ has only one real root, which is the root $x=1$ from the multiplier, leaving none for the original quartic equation $x^4+x^3+x^2+x+1=0$.
Now try $x^4+x^3+x^2+x-1=0$. With $x-1$ as a multiplier we get
$x^5-2x+1=0$
$+000-+$
This gives two possible positive roots and one possible (sure) negative root; discounting the introduced root $x=1$ this means $x^4+x^3+x^2+x-1=0$ could have up to two real roots.
By itself that does not mean the equation does not have all real roots; the roots could correspond to repeated factors. But if there is a root with repeated factors the Rule of Signs will actually count the root with that multiplicity. For instance, $x^3-x^2+x+1=(x+1)(x-1)^2=0$ technically has only one positive root, but the corresponding factor appears twice (squared) and the Rule of Signs will count it as two. With this qualification, the bound of two real roots for $x^4+x^3+x^2+x-1=0$ already includes whatever multiplicity of factors there may be, and we are forced to accept that this case actually does not give all real roots.
We go through all the possible cases and determine whether four real roots are possible after trying out the multiplier $x-1$ as above, and if the equation survives that test we then try it also with the auxiliary factor $x+1$ (which the four-root bound must also survive).
Did I say all the possible cases? Actually if we are smart about our trial choices, we need to test only half of them because if any function $P(x)$ fails with $x-1$ as the multiplier, $P(-x)$ will fail with $x+1$ and vice versa.
Then, if any of our eight trials results in a quartic equation that could have four real roots including appropriate multiple factor-counts, we must examine that case more precisely to see if all those real roots actually exist.

All of the possible cases fail with the Rule of Signs augmented by a factor of $x+1$ or $x-1$. So no fourth-degree equation with all coefficients $\pm1$ can have all roots real. Further testing shows that Descartes' Rule of Signs with the auxiliary factors $x\pm1$ also rules out all possibilities fir degree 5, and it seems likely for higher degrees as well.

A: By the Rational Root Theorem, if such a polynomial has a rational root, it must be $x = \pm 1$.  It turns out that 8 of the 16 possible cubics (the ones with even numbers of + and - coefficients) have such a root.
For a quartic, we get $f(x) = \pm x^4 \pm x^3 \pm x^2 \pm x \pm 1 = \pm 1 \pm 1 \pm 1 \pm 1 \pm 1$, which always works out to an odd number, never zero.  So $f$ has no rational roots.  Proving that there are no real solutions can be done using Descartes' Rule of Signs, as in the other answers.
