and for second no need to delete that very node pointer, take the data of the node next to the node you want to delete and copy that to the node you want to delete, do it for all next nodes. delete the last node.
On Thu, Aug 11, 2011 at 12:12 AM, sukran dhawan <[email protected]> wrote: > reverse the list inplace and compare the two list element by element > > On Thu, Aug 11, 2011 at 12:01 AM, Piyush Kapoor <[email protected]> wrote: >> >> @naveen >> for the first one,how will u traverse the list backwards.. >> I didnt understand your second solution,since the head is not given so >> how can u go from a node to the node to be deleted.. >> >> >> I forgot that in the first one,we are not allowed to use extra memory. >> Also do please mention the time complexity of your solutions.. >> >> On Wed, Aug 10, 2011 at 11:54 PM, Naveen Kumar >> <[email protected]> wrote: >>> >>> for first reverse one of the link list by changing the pointer and >>> than traverse one from backward and compare it the the other. >>> >>> for second. keep copying data from the next node to the node to be >>> delete and remove the tail. This will not work if node to be deleted >>> is the last node. >>> >>> On Wed, Aug 10, 2011 at 11:44 PM, Piyush Kapoor <[email protected]> >>> wrote: >>> > Q1)Two linked Lists are given,i.e,their head pointers are given,and the >>> > problem is to check if the second one is reverse of the first one.Give >>> > the >>> > most efficient algo for it. >>> > Q2)A linked list is given,and one of its nodes is given.The problem is >>> > to >>> > delete the given node from the linked list.(The head node is not >>> > given). >>> > (In both of the above cases,the linked lists are singly linked lists.) >>> > -- >>> > Regards, >>> > Piyush Kapoor, >>> > 2nd year,CSE >>> > IT-BHU >>> > >>> > -- >>> > You received this message because you are subscribed to the Google >>> > Groups >>> > "Algorithm Geeks" group. >>> > To post to this group, send email to [email protected]. >>> > To unsubscribe from this group, send email to >>> > [email protected]. >>> > For more options, visit this group at >>> > http://groups.google.com/group/algogeeks?hl=en. >>> > >>> >>> >>> >>> -- >>> Cheers >>> Naveen Kumar >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Regards, >> Piyush Kapoor, >> 2nd year,CSE >> IT-BHU >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Cheers Naveen Kumar -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
