Check if a linked list is NULL terminated or cyclic