Given a singly linked list find the n-th node from the back.
Click for Solution
  • A let "list ' points to the 1st node

    void Show_nthElementFromLast(node *list ,int n)
    {
    node *pt;
    int i,c=0;
    if(list==NULL)
    printf("empty");
    else
    {
    for(pt=list;pt!=NULL;pt=pt->next)
    c++;
    for(pt=list,i=0;i<c-n;i++,pt=pt->next);
    printf("%d",pt->info);
    }
    }

  • k kjkklkjlklkj

[Insert Code]