tortoise = top hare = top forever: if hare == end : return 'No Loop Found' hare = hare.next if hare == end : return 'No Loop Found' hare = hare.next tortoise = tortoise.next if hare == tortoise: return 'Loop Found'
tortoise = top hare = top forever: if hare == end : return 'No Loop Found' hare = hare.next if hare == end : return 'No Loop Found' hare = hare.next tortoise = tortoise.next if hare == tortoise: return 'Loop Found'