splitList(L):
| Input non-empty linked list L
| Output L split into two halves
|
| // use slow and fast pointer to traverse L
| slow=head(L), fast=head(L).next
| while fast≠NULL ∧ fast.next≠NULL do
| slow=slow.next, fast=fast.next.next // advance pointers
| end while
| cut L between slow and slow.next
|