469,353 Members | 2,053 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

common data structures

hi!

i am reading "how to think like a computer scientist - learning with
python"... it semms like a good tutorial, but it shows a different
language heritage... in particular, in the chapter about linked lists.

the question is: why bothering building a linked list class when you
have a native list type in the first place? 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?

bye

max
Jul 18 '05 #1
1 1076
In <ZQ*********************@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
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Jan van Veldhuizen | last post: by
5 posts views Thread by el_roachmeister | last post: by
4 posts views Thread by Thomas Paul Diffenbach | last post: by
10 posts views Thread by Bart Goeman | last post: by
13 posts views Thread by Leszek Taratuta | last post: by
3 posts views Thread by osp | last post: by
29 posts views Thread by Mik0b0 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.