Doubt in deletion in linked list

In this code I have written a code for deletion at tail of a linked list from ( line 98 ) to ( line 104 ). How should I declare a pointer which points to the previous node from tail ?

hello @yashsharma4304
use one additional pointer that stores address of last visited node.

check now->

It is giving error

declare pointer as *previous .(i missed *)

1 Like

I want to ask one more thing that if we write that :
previous = tail;

then it means previous and tail will point to the same node i.e to the last node. Why you are saying that previous will point to last second node ?

look at this->

   while(tail->next != NULL){
        previous=tail;
        tail = tail->next;
    }

after assigning tail to previous , we are moving tail to next .
thats why previous will not be equal to tail(tail will be next node of previous).

1 Like

Ok yeah… it’s clear now. Thank you very much for your help :slightly_smiling_face:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.