What is the difference between passing Node* as a parameter in Linked List and Node*& as a parameter please clarify I always having doubt .
Guys can anyone explain
hello @rssrivastavarohan
read difference between pass by value and pass by reference in c++.
after that you will be able to differentiate between node * and node *&.
The node *&
notation is a reference to a pointer to a node object, allowing you to change the memory address pointed to by the pointer (through the ref) as well as the node value (through the pointer). Using node *
notation only allows you to achieve the latter.
Please give me a example with full explanation .
yeah right,
function f(node *&x){
modify x.
}
node *p=some address;
f ( p );
in above example when we are passing p to function then it is passed by refernce . In easy langauage now x is exaclty same as p ,just we have another name of p i.e x.
so whatever changes u will make in x is equivalent to making changes in p.
great Aman . One more thing bro where I can study Doubly Linked List . In geeksforgeeks Its complex to understand.
every thing is same as singly linked list ,
just one additional pointer is added each node of the list called prev.
this prev pointer contains address of node that is before/previous to current node in a list.
http://www.btechsmartclass.com/data_structures/double-linked-list.html
https://www.tutorialspoint.com/data_structures_algorithms/doubly_linked_list_algorithm.htm