in the 58th line,why we write tail->next=new node(data)
can we write it as
tail=new node(data)
Inserting at tail
Because we are inserting a new node after the previous tail.
Since we also need to connect the next of the previous tail to the current node we need to write:
tail->next=new node(data)
Without connecting the new node to the previous tail, you cannot traverse and reach that node.
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.