Programming Problem I ( Singly Circular Linked List)
We are given a pointer to the first element of a linked list L. There are two possibilities for L, either it ends (snake) or it points back to head of the list (snail). Give a function that tests whether given list it is a snake or a snail.
void printList(Node* n)
{
while (n != NULL) {
cout << n->data << " ";
n = n->next;
}
}
Comments
Leave a comment