关于使用Python教授数据结构和算法的问题 [英] Questions on Using Python to Teach Data Structures and Algorithms

查看:66
本文介绍了关于使用Python教授数据结构和算法的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我打算用Python来教授学术机构的DSA(数据结构和b $ b和算法)课程。如果您可以通过以下问题帮助
,我一定会很感激:

1. Python列表究竟是什么?如果一个人写[n],那么

复杂性Theta(n)?如果这是O(1),那么为什么选择名称list

?如果这确实是Theta(n),那么应该使用什么替代品来使用?b $ b? (数组似乎不适合教学目的。)

2.假设我有一些文件example.py,我想把它加入

**到** HTML页面的一部分,具有良好的语法高亮和所有

shebang。有没有一种简单的方法可以这样做?

(对不起,但任何涉及Python和HTML的任何Google查询(以及任何

其他附加条款)都是如此到Python HTML处理库。)

3.是否有任何有用的Python / DSA教育链接?我找到了数据

面向对象设计模式的结构和算法

http://www.brpreiss.com/books/opus7/html/book.html) 。这是一本很好的书,

但它不合适:我的学生都是电气工程师,而且几乎不知道如何编程;教他们DSA,python,**和**之类的东西,比如

访客模式似乎是不可能的。


Python是如此酷的语言 - 我是真的希望学生们能像我一样享受它。再一次,非常感谢你帮忙解决这个问题。


谢谢,


Efrat

解决方案

efrat:


> 1。什么是Python列表?



一个动态数组,可以在右边几何增长。


>如果写一个[n],然后是复杂性Theta(n)?如果这是O(1),则<



这是O(1)。


>那么为什么是这个名字]清单"选择?



我也很想知道为什么错误的列表为他们选择了名称,

而不是数组。 (也许是因为list更短,或者因为ABC

称它们为list......)


> 2。假设我有一些文件example.py,我想将它结合到



**到**页面的**部分,语法高亮,并且全部

shebang。有没有一种简单的方法可以这样做?<


有很多程序可以做到这一点,我使用的是修改版的

PySourceColor:
http://bellsouthpwp.net/m/e/mefjr75/

使用Python教授数据结构和算法

电气工程师学生:

以下个人观点可能看似错误,但如果是错误,

比我想知道为什么。

我认为Python只是部分适合你的目的。如果你想

教一些复杂的数据结构如何工作,还有一些聪明的算法,比如教一些有趣的图算法,

然后Python是合适的,因为实现这样的算法通常很简单等等。

但是为了管理简单的数据结构,Python并不好,因为它是'

与简单操作相比太慢了,而且它使用了太多的内存。其中一个基本的数据结构是链式列表,你可以在Python中轻松实现一个链式列表,但结果往往是没有意义的,没有意义,甚至可能是教学目的。 Python

太高级,而大多数基本数据结构使用

指针,如果更接近金属,它们就有了意义。使用

Python,你不能有指针(只是对象的名字),有时候如果你使用快速的话,就不会有b $ b。使用像dicts这样的内置数据结构,你使用比b / b
更慢的数据结构。所以要向你的电气工程师学生讲授一些

基本数据结构我认为

Pascal仍然是最好的选择:-)

(注意:向CS学生教授DS也可以很合适,并且教给我一些年轻人可以更好的教育。)


再见,

bearophile


efrat写道:


1.究竟什么是Python列表?如果一个人写[n],那么

复杂性Theta(n)?如果这是O(1),那么为什么选择名称list

?如果这确实是Theta(n),那么应该使用什么替代品来使用?b $ b? (数组似乎不适合教学目的。)



python列表的索引是O [1]。为什么他们不应该被命名为名单?


2.假设我有一些文件example.py,我想加入它

**进入**页面的一部分,语法高亮,并且所有

shebang。有没有一种简单的方法可以这样做?

(对不起,但任何涉及Python和HTML的任何Google查询(以及任何

其他附加条款)都是如此到Python HTML处理库。)



查看MoinMoin,它为python以及其他语言着色和

文本类型: http://moinmoin.wikiwikiweb.de/HelpOnFormatting


3. Python / DSA教育是否有任何有用的链接?我找到了数据

面向对象设计模式的结构和算法

http://www.brpreiss.com/books/opus7/html/book.html) 。这是一本很好的书,

但它不合适:我的学生都是电气工程师,而且几乎不知道如何编程;教他们DSA,python,**和**之类的东西,比如

访客模式似乎是不可能的。



Beginning Python - 从新手到专业人士是平易近人的,并且作为教科书IMO非常棒。作为奖励,它涵盖了python 2.4,其中很少有现有书籍。


George


在< 45 ****** @ news.bezeqint.net> ;, efrat写道:


1.到底是什么一个Python列表?如果一个人写[n],那么

复杂性Theta(n)?如果这是O(1),那么为什么选择名称list




为什么不呢?它具有从抽象数据类型中获得的所有方法

list。它不是O()行为,而是定义抽象

数据类型的接口。如果它是一个(双)链表或

引擎盖下的动态阵列是一个实现细节。


Ciao,

Marc''BlackJack''Rintsch


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:

>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


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 python lists is O[1]. Why shouldn''t they be named 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?
(Sorry, but any Google query involving "Python" and "HTML" (with any
other additional terms) led to Python HTML processing libraries.)

Check out MoinMoin, it colorizes python as well as other languages and
text types: http://moinmoin.wikiwikiweb.de/HelpOnFormatting

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.

"Beginning Python - From Novice to Professional" is approachable and
great as a textbook IMO. As a bonus, it covers up to python 2.4, which
very few existing books do.

George


In <45******@news.bezeqint.net>, 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 the interface that defines abstract
data types. If it''s a (double) linked list or a dynamical array under the
hood is an implementation detail.

Ciao,
Marc ''BlackJack'' Rintsch


这篇关于关于使用Python教授数据结构和算法的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆