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



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,
instead of "array". (Maybe because "list" is shorter, or because ABC
called them "lists"...)


2. Suppose I have some file example.py, and I'd like to incorporate it
**into** part of an HTML page with nice syntax highlighting and all the
shebang. Is there an easy way to do so?<

There are many programs that do this, I use a modified version of
PySourceColor:
http://bellsouthpwp.net/m/e/mefjr75/


Using Python to teach data structures and algorithms to
electrical-engineers students:
The following personal ideas may seem wrong, but if they are wrong,
than I'd like to know why.
I think Python is only partially fit for your purpose. If you want to
teach how complex data structures work in general, and some smart
algorithms on them, like teaching some interesting graph algorithms,
then Python is fit, because implementing such algorithms is often
simple, etc.
But to manage simple data structures Python isn't good, because it's
too much slow compared to the simple operations, and it uses too much
memory. One of the basic data structures is the chained list, you can
easly implement a chained list in Python, but the result is often
useless and without meaning, maybe even for teaching purposes. Python
is too much hi-level, while most of the basic data structures use
pointers and they have a meaning if done closer to the 'metal'. With
Python you can't have pointers (just names of objects) and some times
if you use a "fast" data structure you end doing things slower than
using the built-in data structures like dicts. So to teach some of the
basic data structures to your electrical-engineers students I think
Pascal is the best choice still :-)
(Note: to teach DSA to CS students C can be fit too, and to teach a bit
of DSA to younger people Python can be better.)

Bye,
bearophile

.



Relevant Pages

  • Re: Questions on Using Python to Teach Data Structures and Algorithms
    ... use Python? ... good) books that used Pascal for this topic. ... "Data Structures and Algorithms with Object Oriented Design Patterns" ...
    (comp.lang.python)
  • Re: Ordering python sets
    ... As Python becomes accepted for more and more "serious" projects some ... SortedSet, SortedDict: can be based on red-black trees. ... I use all those data structures in Python programs, plus some more, ... A problem with the Chain data structure is how to represent iterators ...
    (comp.lang.python)
  • Re: variable question
    ... tutoring some kids about basics of programming using python. ... order data structures. ... The important thing is really that Python's approach of references is ...
    (comp.lang.python)
  • Re: Newbie completely confused
    ... Your program uses quite a bit of memory. ... And really, reading 30MB files should not be such a problem, right? ... 'del LINES' deletes the lines that are read from the file, but not all of your data structures that you created out of them. ... The python code loads a module written in C++ and some of the member variables actually point to C++ objects created dynamically, so one actually has to call their destructors before unbinding the python var. ...
    (comp.lang.python)
  • Re: Python evolution: Unease
    ... I still think numarray is a good start for this. ... >>represented by the csv module are a lot shallower than those represented by ... > necessary stuff (I'm not even half done in learning Python) ... > and clear_ manipulations of rich data structures in Python. ...
    (comp.lang.python)