ProAnswers.org

algorithm for Counting the elements of linked list

algorithm for Counting the elements of linked list

typedef struct node{

	    int data;

	    struct node *next;

	}node;

	 

	int count_list(node *head){

	    node *move;

	    int count = 0;

	    for(move = head; move != NULL; move = move->next)

	        count++;

	    return count;

	}