An Optimal Agorithm for Symbolic Factorization of Symmetric Matrices