Berlekamp-Massey Algorithm