algorithms, homework six.