Re: recursion and linked lists

2006-04-07 Thread Ed Singleton
On 01/04/06, John Salerno <[EMAIL PROTECTED]> wrote: > I V wrote: > > > > Note that print gets called after _each_ time that printBackward > > returns. So, as the different calls to printBackward return, they print > > whatever 'head' was set to in that invocation. Now, logically enough, > > the la

Re: recursion and linked lists

2006-03-31 Thread John Salerno
I V wrote: > Note that print gets called after _each_ time that printBackward > returns. So, as the different calls to printBackward return, they print > whatever 'head' was set to in that invocation. Now, logically enough, > the last call to printBackward is the first to return, so the last > va

Re: recursion and linked lists

2006-03-31 Thread I V
John Salerno wrote: > The printable value of node1 is 1, node2 is 2 and node 3 is 3. > > node1.next is node2, node2.next is node3 and node3.next is None. > > This might be painfully obvious, but I don't understand when the print > statement is getting called. If you call printBackward with node1, t

recursion and linked lists

2006-03-31 Thread John Salerno
Can someone explain to me how this works: def printBackward(list): if list == None: return head = list tail = list.next printBackward(tail) print head, >>> printBackward(node1) 3 2 1 The printable value of node1 is 1, node2 is 2 and node 3 is 3. node1.next is node2, node2.next