In the push function we are passing head by value. Shouldn’t it be a pass by reference?
About the push function
@aslesha.j7 hey ,it all depend upon you ki apko pass by value krna hai ya reference ,pass by value is easy in this case,so I suggest you that.
but if we don’t do pass by value the in main how will our head change accordingly? in all prev videos we did it like that only so that corresponding changes are reflected back in the main.
@aslesha.j7 aap pass by reference islie krte hai taki apko original me change krna ho in main and function kuch return na kre uske changes hmare main me reflect hojaye but agr apne pass by value kia to apko nya head return krna pdega and niche main me use point krne ke lie pointer lena pdega .Hope I cleared your doubt )
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.
fuction kuch return ni kr rha fr bhi hmne pass by value kea hai. To main me kese changes reflect honge?
Which code are you referring to?
Here clearly head is passed by reference. Since you are modifying the Linked list in this function (And the position of head might change) so you need to pass the head by reference…so that changes are reflected in the main.
okay thanks for the help
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.