Put every eigenvalue of A in the equation of B to get the respective eigenvalue of B [ The Cayley-Hamilton Theorem ]
let b1, b2, b3, and b4 are the eigenvalues of B and a1, a2, a3 and a4 are the eigenvalues of A
a1 = -1, a2 = 1, a3 = 2, a4 = -2
$b_{1} = a_{1}^{4} - 5a_{1}^{2} + 5$
$b_{2} = a_{2}^{4} - 5a_{2}^{2} + 5$
$b_{3} = a_{3}^{4} - 5a_{3}^{2} + 5$
$b_{4} = a_{4}^{4} - 5a_{4}^{2} + 5$
on putting values of a1,a2,a3 and a4, we get
b1 = 1, b2 = 1, b3 = 1 and b4 = 1
trace of a matrix = sum of eigenvalues
trace(A + B ) = trace(A) + trace(B)
trace(A) = -1 + 1 + 2 -2 = 0
trace(B) = 1 + 1 + 1 + 1 = 4
trace(A + B ) = 0 + 4 = 4