The Solution is pretty straight forward when you long number is represented
in reverse order in linked list.
If the number is not in reverse order, We need an Explicit stack or we must
Use Recursion .
Other way around this is to construct another parallel linked list along
with Sum(linked list)
@Dave..Can u provide a small snippet for ur explanation pls..
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
int add(struct node* pL1, struct node * pl2,int gap/*no of digits in l1 -no
of digits in l2*/)
{ //assumption, # of nodes in L1 is # of nodes in L2, make sure this
before calling this, counting nodes is less costlier than reversal
if (!(pl1) || !(pl2)) return 0;
if (gap0)
{
carry =
i think we can access numbers from last so no need to reverse it and also we
can store it in linke list in stack way so again no need to reverse the
linked list.
On Sat, Aug 14, 2010 at 7:03 PM, Gaurav Singh gogi.no...@gmail.com wrote:
Reversing the lists and then adding and then reversing the
how can you traverse from last without reversing it.
and there is no need fof using extra stack space.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this
I men to say ki just traverse from last instead of reversing it and storing
result in a stack in linked list form so that we dont need to reverse
again.Hope,i made myself clear.
On Sat, Aug 14, 2010 at 11:40 PM, Lokesh Agarwal lokesh...@gmail.comwrote:
how can you traverse from last without
Reversing and then again reversing the answer will not be an efficient
algorithm...
on the fly computation of sum must be done...any ideas
On 8/14/10, Rahul Singhal nitk.ra...@gmail.com wrote:
I men to say ki just traverse from last instead of reversing it and storing
result in a stack in
i think we can use recursion method to reverse the list
-- Prashant Kulkarni
On Sat, Aug 14, 2010 at 11:40 PM, Lokesh Agarwal lokesh...@gmail.comwrote:
how can you traverse from last without reversing it.
and there is no need fof using extra stack space.
--
You received this message