Well, we can do one thing but it might not work in all cases.

First of all you need to know the node structure. Assume it has an int and 
a next pointer.

Assumption - Memory allocation for nodes did not happened at random 
location but uniformly. 
1. Find out the memory address contained in the next pointer of current 
node. Compute the difference between address of current and next node.
2. Compute the address for previous node (to check the above assumption, 
figure out the address at memory for the next pointer is allocated, check 
the contents of that pointer, if that content matches the memory location 
of the current node address , then our above assumption was right.
3. Now we have the address of the last node, copy the current node's data 
in the last node and modify it's next pointer to point to current node's 
next 
we can also have a temporary pointer for recording the location of current 
node and deleting it after step.3

Hope the solution is clear.

On Tuesday, 10 July 2012 01:36:17 UTC+5:30, subharansu wrote:
>
> Is there any solution which will take care deleting a node Given only a 
> pointer to a node to be deleted in a singly linked list( 
> *How Do we consider deleting the last node*) *
> *
>
> *Subhransu 
> *
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/u2WRmvPkGTUJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to