common data structures

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat Jul 31 17:19:45 EDT 2004


In <ZQTOc.62330$OR2.3487149 at news3.tin.it>, max(01)* wrote:

> the question is: why bothering building a linked list class when you 
> have a native list type in the first place?

To show how the native list type may be implemented.  It's not BTW.  And
of course it's a book to learn to think like a computer scientist in
general and not like a python programmer.

> the same applies about 
> trees, which can naturally be encoded like lists, e.g.:
> 
> 
>        1
>       / \
>      2   3           --->     [1, [2, [4, 5]], 3] maybe...
>     / \
>    4   5
> 
> is it a teaching contrived example, a matter of performance or what else?

That's a quite simple example and usually you want not only the data
representation but operations on that tree like in-order tree walk and
similar things.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list