completed mergearrays algorithm