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
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
@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
reverse the list inplace and compare the two list element by element
On Thu, Aug 11, 2011 at 12:01 AM, Piyush Kapoor pkjee2...@gmail.com 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
Ques 1:
Let l1 and l2 be the 2 lists.
Step 1 : Reverse l1 O(n)
Step 2 : Compare l1 and l2 by comparing each node and traversing
ahead.--O(n)
Step 3: Reverse l1 -O(n)
Ques 2:
Let cur be the node of the linked list which is to be
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 sukrandha...@gmail.com wrote:
1)similar to list palindrome problem(soln already there in net)
2)it has discussed 2 day before on same group. please search once
Thank you,
Siddharam
On Thu, Aug 11, 2011 at 12:01 AM, Piyush Kapoor pkjee2...@gmail.com wrote:
@naveen
for the first one,how will u traverse the list backwards..
thanks all
On Thu, Aug 11, 2011 at 12:21 AM, siddharam suresh
siddharam@gmail.comwrote:
1)similar to list palindrome problem(soln already there in net)
2)it has discussed 2 day before on same group. please search once
Thank you,
Siddharam
On Thu, Aug 11, 2011 at 12:01 AM, Piyush
1)for the fst one you dont have to reverse the linked list just traverse the
linked list recursively and read it from back .
correct me if m wrong !
On Thu, Aug 11, 2011 at 12:41 AM, Piyush Kapoor pkjee2...@gmail.com wrote:
thanks all
On Thu, Aug 11, 2011 at 12:21 AM, siddharam suresh