Recursion can be used as a approach.
void disp( node * head, int i)
{
i++;
if(i > n || head == NULL)
return;
disp(head->next,i);
if(head != NULL)
cout << head->data << endl;
}
first call this function with pointer to head and 0;
disp(first,0);
then increment the pointer to 3(as in example)
and again call the same function.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.