Why pass by reference not value

why are we passing head as a reference, not by value?

@itsmeshubhamkumar Whenever you want changes to be reflected in your original Linked List you pass it as reference as in case of inserting an element or removing an element from the linked list.
When no change in the Linked list is involved, as in case of printing the linked list then you pass it by value.

1 Like