Self function

Carl Banks pavlovevidence at
Tue May 5 01:33:13 CEST 2009

On May 4, 4:06 pm, bearophileH... at wrote:
> Carl Banks:
> >1. Singly-linked lists can and should be handled with iteration.<
> I was talking about a binary tree with list-like topology, of course.

"(every node has 1 child, and they are chained)"

That's a singly-linked list, not a tree.  It's a degenerate tree at

> >All recursion does it make what you're doing a lot less readable for almost all programmers.<
> I can't agree.

If every child has one node you don't need recursion.

> If the data structure is recursive (like a tree, or
> even sometimes graphs, etc) a recursive algorithm is shorter, more
> readable and more natural.

Because that's a tree, not a linked-list.

Which is germane because Python's recursion limit is the thing you're
complaining about here, and you don't normally hit that limit with
real trees because they rarely go 1000 deep.

Singly-linked lists don't count because you don't need recursion for

[snip strawman example]
> > 2. You should be using a Python list anyway.
> I should use D when I have to use such algorithms, I know.

That's another idea.

Carl Banks

More information about the Python-list mailing list