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 deleted.

LinkedList temp=cur->next;
cur->data=temp->data;
cur->next=temp->next;
free(temp);

TC : O(1)
This solution does not work if cur is the last node of the link list. In
that case u will have to traverse the whole link list and TC will be O(n)

-- 
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