chai said:
I am trying out a program to insert an element to a sorted list(singly
linked list)without using the temporary variable.Is there a solution
for this problem?
I presume you mean you don't want to walk a pointer down the list looking
for the correct spot to insert.
One way would be to write a recursive insert function. Call it with a
pointer to the list, and have it call itself with the pointer to the next
node in the list until it finds the insertion point. (Not gonna write the
code for you, junior. But it ain't that hard.)
That would be a fucking stupid way to do it, though. A temporary pointer
requires a lot less memory and fewer CPU cycles.