omprakpal
BAN USER
Comments (6)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
space O(1)...recursion...
node *merge(node *l1,node *l2)
{
if(l1==NULL) return l2;
if(l2==NULL) return l1;
if(l1->value==l2->value)
{
l1->next=merge(l1->next,l2->next); //to handle duplicate..
delete l2;
return l1;
}
if(l1->data>l2->data)
{
l2->next=merge(l1,l2>next);
return l2;
}
l1->next=merge(l1->next,l2);
return l1;
}
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
@devendra..u r right..internally it will take O(n) spce but if you will it in non-recursive way(just implement by using while loop).then it will O(1)..
- omprakpal July 27, 2011