Added serial implementation of the algorithm