Re: Questions on Using Python to Teach Data Structures and Algorithms

2007-11-08 Thread Scott David Daniels
Wayne Brehaut wrote: ... > For learning DSA it's more important to have a clear, well-written and > well-documented implementation in a language of interest (again, > especially, the core language in one's programs) than just "using" or > even inspecting and trying to learn subtle details of some p

Re: Questions on Using Python to Teach Data Structures and Algorithms

2007-11-07 Thread Wayne Brehaut
On Thu, 28 Sep 2006 17:32:06 +0200, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >Ramon Diaz-Uriarte wrote: > >> Going back to the original question, a related question: does anybody >> know why there are so few books on data structures and algorithms that >> use Python? > >Probably because Python has

Re: Questions on Using Python to Teach Data Structures and Algorithms

2007-11-07 Thread Wayne Brehaut
On Thu, 28 Sep 2006 17:23:25 +0200, "Ramon Diaz-Uriarte" <[EMAIL PROTECTED]> wrote: >Going back to the original question, a related question: does anybody >know why there are so few books on data structures and algorithms that >use Python? > >I remember that, at least ~ 12 years ago there were man

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-29 Thread sturlamolden
MonkeeSage wrote: > > def cons(car,cdr): return (car,cdr) # or [car,cdr] > > def car(cons): return cons[0] > > def cdr(cons): return cons[1] > > I guess you were talking about implementing the _structure_ of lisp > lists in python syntax (as you seem to imply), not trying to emulate > their _behav

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-29 Thread Bruno Desthuilliers
Dennis Lee Bieber wrote: > On 28 Sep 2006 21:17:38 -0700, "MonkeeSage" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > (Coming in from the cold) >> I guess you were talking about implementing the _structure_ of lisp >> lists in python syntax (as you seem to imply), not

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread MonkeeSage
Dennis Lee Bieber wrote: > Though if this suddenly inspires the creation of a Common LISP > interpreter written in Python, I may want to close my eyes Hehe! I actually thought of trying that once, but I realized that I'm too stupid and / or lazy to pull it off. ;) Regards, Jordan -- http

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread MonkeeSage
sturlamolden wrote: > Thus I stand by my original claim. Essentlially: > > def cons(car,cdr): return (car,cdr) # or [car,cdr] > def car(cons): return cons[0] > def cdr(cons): return cons[1] I guess you were talking about implementing the _structure_ of lisp lists in python syntax (as you seem to i

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Gabriel G
At Thursday 28/9/2006 12:23, Ramon Diaz-Uriarte wrote: Going back to the original question, a related question: does anybody know why there are so few books on data structures and algorithms that use Python? I remember that, at least ~ 12 years ago there were many (and very good) books that use

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Ramon Diaz-Uriarte
On 9/28/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Ramon Diaz-Uriarte wrote: > > > Going back to the original question, a related question: does anybody > > know why there are so few books on data structures and algorithms that > > use Python? > > Probably because Python has "better than textbo

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread sturlamolden
Brendon Towle wrote: > ? (cons ) > > returns a single level list, with as its new first item, and > the original contents of as the remainder of the list. The > OP's code doesn't do that; it returns a list of two items, with > as the second item. That is equivalent, as is the remainder of t

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread sturlamolden
sturlamolden wrote: > Remember that O(1) is not neccesarily faster than O(N)! Unless your > linked list is very big, you will get something called a 'cache miss' > inside your CPU. Thus it is usually more efficient to work with dynamic > arrays. This was a bit ackwardly formulated. What I was tr

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Fredrik Lundh
sturlamolden wrote: > I seem to remember that a cons joins two items, it doesn't grow a > strait list. http://www.lisp.org/HyperSpec/Body/fun_cons.html "If object-2 is a list, cons can be thought of as producing a new list which is like it but has object-1 prepended." -- http://mail.python.

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread sturlamolden
Brendon Towle wrote: > > def cons(a,b) > >return [a,b] > > should be: > return [a].extend(b) I seem to remember that a cons joins two items, it doesn't grow a strait list. A lisp list is a special case of a binary tree. How would you build a tree structure with your cons? I think you ar

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Brendon Towle
On 28 Sep 2006, at 12:45 PM, [EMAIL PROTECTED] wrote: > From: "MonkeeSage" <[EMAIL PROTECTED]> > Subject: Re: Questions on Using Python to Teach Data Structures and > Algorithms > To: python-list@python.org > > [snip] > But Brendon's code also

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread MonkeeSage
Bruno Desthuilliers wrote: > Brendon Towle wrote: > > Some of your Lisp translations are subtly off... > > Seems correct to me. Lisp lists are linked lists, not arrays. Actually, Brendon was correct. In lisp / scheme: (cons 1 '(2 3)) -> (1 2 3) (car '(1 2 3)) -> 1 (cdr '(1 2 3)) -> (2 3) But Bre

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Steve Holden
Brendon Towle wrote: > Some of your Lisp translations are subtly off... > > > >>Date: 28 Sep 2006 02:49:50 -0700 >>From: "sturlamolden" <[EMAIL PROTECTED]> >>Subject: Re: Questions on Using Python to Teach Data Structures and >> Algorit

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Fredrik Lundh
Ramon Diaz-Uriarte wrote: > Going back to the original question, a related question: does anybody > know why there are so few books on data structures and algorithms that > use Python? Probably because Python has "better than textbook" implementations of core structures, and "better than textboo

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
Brendon Towle wrote: > On 28 Sep 2006, at 8:05 AM, [EMAIL PROTECTED] wrote: > >> From: Bruno Desthuilliers <[EMAIL PROTECTED]> >> >> Brendon Towle wrote: >>> Some of your Lisp translations are subtly off... >> >> Seems correct to me. Lisp lists are linked lists, not arrays. >> >>> From: "stur

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Ramon Diaz-Uriarte
Going back to the original question, a related question: does anybody know why there are so few books on data structures and algorithms that use Python? I remember that, at least ~ 12 years ago there were many (and very good) books that used Pascal for this topic. So when I did my own search for o

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Steve Holden
[EMAIL PROTECTED] wrote: > efrat: [...] > >>then why was the name "list" chosen? > > > I'd too love to know why the wrong "list" name was chosen for them, > instead of "array". (Maybe because "list" is shorter, or because ABC > called them "lists"...) > I suspect it's because of their intrinsic

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Brendon Towle
On 28 Sep 2006, at 8:05 AM, [EMAIL PROTECTED] wrote: > From: Bruno Desthuilliers <[EMAIL PROTECTED]> > Subject: Re: Questions on Using Python to Teach Data Structures and > Algorithms > To: python-list@python.org > > Brendon Towle wrote: >> Some of your Li

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bryan Olson
efrat wrote: > I'm planning to use Python in order to teach a DSA (data structures > and algorithms) course in an academic institute. If you could help out > with the following questions, I'd sure appreciate it: > 1. What exactly is a Python list? It's almost exactly what the doc says (and exa

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
Brendon Towle wrote: > Some of your Lisp translations are subtly off... Seems correct to me. Lisp lists are linked lists, not arrays. > >> Date: 28 Sep 2006 02:49:50 -0700 >> From: "sturlamolden" <[EMAIL PROTECTED]> >> Subject: Re: Questions on U

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Brendon Towle
Some of your Lisp translations are subtly off... > Date: 28 Sep 2006 02:49:50 -0700 > From: "sturlamolden" <[EMAIL PROTECTED]> > Subject: Re: Questions on Using Python to Teach Data Structures and > Algorithms > To: python-list@python.org > > If you w

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread sturlamolden
efrat wrote: > 1. What exactly is a Python list? If one writes a[n], then is the > complexity Theta(n)? If this is O(1), then why was the name "list" > chosen? If this is indeed Theta(n), then what alternative should be > used? (array does not seem suited for teaching purposes.) A Python list is

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
efrat wrote: > Hello, > > I'm planning to use Python in order to teach a DSA (data structures > and algorithms) course in an academic institute. If you could help out > with the following questions, I'd sure appreciate it: (snip) > 2. Suppose I have some file example.py, and I'd like to incorp

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-27 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, efrat wrote: > 1. What exactly is a Python list? If one writes a[n], then is the > complexity Theta(n)? If this is O(1), then why was the name "list" > chosen? Why not? It has all the methods one expect from an abstract data type "list". It's not the O() behavior but t

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-27 Thread George Sakkis
efrat wrote: > 1. What exactly is a Python list? If one writes a[n], then is the > complexity Theta(n)? If this is O(1), then why was the name "list" > chosen? If this is indeed Theta(n), then what alternative should be > used? (array does not seem suited for teaching purposes.) Indexing for pyth

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-27 Thread bearophileHUGS
efrat: >1. What exactly is a Python list? A dynamic array that can grow geometrically on the right. >If one writes a[n], then is the complexity Theta(n)? If this is O(1),< It is O(1). >then why was the name "list" chosen? I'd too love to know why the wrong "list" name was chosen for them, i

Questions on Using Python to Teach Data Structures and Algorithms

2006-09-27 Thread efrat
Hello, I'm planning to use Python in order to teach a DSA (data structures and algorithms) course in an academic institute. If you could help out with the following questions, I'd sure appreciate it: 1. What exactly is a Python list? If one writes a[n], then is the complexity Theta(n)? If

Questions on Using Python to Teach Data Structures and Algorithms

2006-09-27 Thread efrat
Hello, I'm planning to use Python in order to teach a DSA (data structures and algorithms) course in an academic institute. If you could help out with the following questions, I'd sure appreciate it: 1. What exactly is a Python list? If one writes a[n], then is the complexity Theta(n)? If