here head is already a pointer variable then why do we need to pass it by reference?
wasn’t it so that we didn’t need to pass adresses by reference? like in the case of arrays we don’t pass it by reference because it’s name represents the adress of the first cell. then why are we passing the head by reference?
Passing by reference
@alankrit.agr99 hey ,it is not necessary to pass head as reference ,but we do so to make changes in the original head of linked list itself so that we don’t have to return the head ,but you can do it without reference take the return type of function as node * and return the head in which you make changes.Hope you get it:)
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.