On Mon, Aug 8, 2011 at 8:08 PM, sukran dhawan <[email protected]>wrote:
> struct node * fun(struct node * list,int n)
{
struct node *p,*q ;
p = q = list;
int n1 = 1;
while(p->next != NULL)
{
if(n1 <n)
{
n1++;
p = p->next;
}
else
{
p=p->next;
q = q->next;
}
}
return q;
}
>
>
>
> On Mon, Aug 8, 2011 at 8:06 PM, jagrati verma <[email protected]
> > wrote:
>
>> hw is it possible frm this code ???????????/
>>
>>
>>
>>
>> Node * findNToLastNode( Node *head, int N )
>> {
>> int i = 0;
>> Node *current, *behind;
>> current = head;
>> for( i = 0; i < N; i++ ) {
>> if( current->next ) {
>> current = current->next;
>> } else {
>> return NULL; // Length of the list is less
>> than N
>> }
>> }
>>
>> behind = head;
>> while( current->next ) {
>> current = current->next;
>> behind = behind->next;
>> }
>>
>> return behind;
>> }
>>
>> --
>> 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.
>>
>>
>
--
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.