hunt's algorithm