Ankur, you are rite.

He mentioned that we may not know what the data might be. And yes, I agree
that he kept the restriction because we may not know what the data is. In
that case, I guess bit by bit copying of data from the next node to the
current node (it is possible since both the nodes are of same size) and
deleting the next node might be the only solution.

Anyway, thanks to all for replying :) I owe you guys one :)

On Fri, Apr 8, 2011 at 1:08 PM, ankur bhardwaj <ankibha...@gmail.com> wrote:

> For the 2nd ques, wat i think is the interviewer has kept the restriction
> of not moving the data since you may have a linked list about which you
> donot have much information about the structure of the node of the list(only
> know about the next pointer) and hence you cannot move the data. For that,
> you can free the middle node and copy the last node bit by bit at the
> location of the middle node.
>
> If you still dont want to use the method above, you will have to free the
> middle node and reallocate the next node at the location of the middle node.
> For this wat i could think was to use the realloc() and put it in a while
> loop and terminate the loop only when the address returned matches with the
> address possesed by the middle node. But this method is not efficient and
> also unwise. If anyone can think of something better, he/she is invited
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> 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.
>



-- 
Umer

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
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