Originally Posted by
Mr.777
Depends....
In some cases, it's recommended to pass by reference but mostly yes we try to pass by reference...
First, think about your problem.
Second, add the node :-)
Suppose i got 5,12,34,3,9 as data part and i want to insert in order.
So first it's 5, i'll check if there is already a node, if no, i'll create node and put my data.
Then 12, i'll compare it with 5, and insert to the next.
34, greate than 12, insert in front.
3, smaller than 34, go to the rear of 34, it's 12, compare with 12, again it's smaller, go to the rear of 12, it's 5, compare and smaller, go to the rear of 5, it's null, now two ways.
i). Create new node and point it's next to 5.
ii). From 5's rear, create a node whom 5 will point..