Questions on Using Python to Teach Data Structures and Algorithms

Discussion in 'Python' started by efrat, Sep 28, 2006.

  1. efrat

    efrat Guest

    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 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.)
    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?
    (Sorry, but any Google query involving "Python" and "HTML" (with any
    other additional terms) led to Python HTML processing libraries.)
    3. Are there any useful links for Python/DSA education? I found "Data
    Structures and Algorithms with Object Oriented Design Patterns"
    (http://www.brpreiss.com/books/opus7/html/book.html). It is a fine book,
    but it is unsuitable: my students are electrical-engineers, and barely
    know how to program; teaching them DSA, python, **and** stuff like the
    visitor pattern seems impossible.

    Python is such a cool language - I'm really hoping the students will
    enjoy it as much as I do. Once again, many thanks for helping out with this.

    Thanks,

    Efrat
     
    efrat, Sep 28, 2006
    #1
    1. Advertising

  2. 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 incorporate it
    > **into** part of an HTML page with nice syntax highlighting and all the
    > shebang. Is there an easy way to do so?


    I suppose this has more to do with the course presentation than with
    it's content !-)

    However, Trac's wiki is probably a good solution here.

    --
    bruno desthuilliers
    python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
    p in ''.split('@')])"
     
    Bruno Desthuilliers, Sep 28, 2006
    #2
    1. Advertising

  3. efrat

    Bryan Olson Guest

    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 exactly what the code
    implements).

    > If one writes a[n], then is the complexity Theta(n)?


    No; as others have pointed out, it's O(1).

    > If this is O(1), then why was the name "list" chosen?


    Because it *is* a list: an ordered collection in which an
    element might appear multiple times. It's also an extensible
    array, but that's so more verbose.

    > If this is indeed Theta(n), then what alternative should be
    > used? (array does not seem suited for teaching purposes.)


    It's not Theta(n), and the array classes are fine for teaching.

    > 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?


    Yes. In fact its probably easier, or at least no harder, than
    making sense of what you mean there.

    > (Sorry, but any Google query involving "Python" and "HTML" (with any
    > other additional terms) led to Python HTML processing libraries.)


    Don't be sorry about about getting the info you need (whether
    or not you realize it is the info you need).

    > 3. Are there any useful links for Python/DSA education?


    Yes, many. Python is fine for teaching data structures and algorithms.
    Python's loosely-defined "duck typing" makes it pedagogically
    inappropriate for some topics, but as far as you have described your
    course, Python should work well.

    > I found "Data
    > Structures and Algorithms with Object Oriented Design Patterns"
    > (http://www.brpreiss.com/books/opus7/html/book.html). It is a fine book,
    > but it is unsuitable: my students are electrical-engineers, and barely
    > know how to program; teaching them DSA, python, **and** stuff like the
    > visitor pattern seems impossible.


    When I taught algorithms, I observed that my students arrived lacking
    much of the background knowledge I would expect, but they more than
    compensated by being so bright. The engineers did about as well as
    comp-sci students. We all got blown away by a couple scary-smart math
    majors.

    You don't need to teach, or know, the visitor pattern. Deal with the
    the fundamentals. There are two ways we describe specific computational
    problems: output as a function of input, and abstract data type. Python
    is great for both.


    --
    --Bryan
     
    Bryan Olson, Sep 28, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. efrat
    Replies:
    14
    Views:
    774
    Scott David Daniels
    Nov 9, 2007
  2. Brendon Towle
    Replies:
    4
    Views:
    328
    Fredrik Lundh
    Sep 28, 2006
  3. Brendon Towle
    Replies:
    8
    Views:
    455
    sturlamolden
    Sep 29, 2006
  4. Alfonso Morra
    Replies:
    11
    Views:
    740
    Emmanuel Delahaye
    Sep 24, 2005
  5. Victor Bazarov
    Replies:
    2
    Views:
    329
    Jorgen Grahn
    Jun 3, 2010
Loading...

Share This Page