Algorithms using Python?

88888 Dihedral dihedral88888 at googlemail.com
Thu Sep 27 07:15:55 EDT 2012


Wayne Werner於 2012年9月27日星期四UTC+8上午12時05分31秒寫道:
> On Fri, 21 Sep 2012, Dennis Lee Bieber wrote:
> 
> 
> 
> > On Fri, 21 Sep 2012 14:26:04 +0530, Mayuresh Kathe <mayuresh at kathe.in>
> 
> > declaimed the following in gmane.comp.python.general:
> 
> >
> 
> >> Is there a good book on foundational as well as advanced algorithms
> 
> >> using Python?
> 
> >>
> 
> > 	Depends on what you mean by "foundational"...
> 
> >
> 
> > 	Since Python has dynamic lists and dictionaries, I suspect you won't
> 
> > find any textbook focusing on linked-list or hashed lookup algorithms
> 
> > using Python.
> 
> >
> 
> > 	You can probably implement them, but they're not going to be very
> 
> > efficient. (And never "remove" an element from the linked-list
> 
> > implementation because Python would shift all the other elements, hence
> 
> > your "links" become invalid).
> 
> 
> 
> It's quite inefficient, but it would be fairly trivial to create a LL 
> 
> implementation like this:
> 
> 
> 
> class Link:
> 
>      def __init__(self):
> 
>          self.next = None
> 
>          self.value = None
> 
> 
> 
> class LinkedList:
> 
>      def __init__(self):
> 
>          self.head = None
> 
> 
> 
>      def add(self, value):
> 
>          node = Link()
> 
>          node.value = value
> 
>          self.append(node)
> 
> 
> 
>      def append(self, node):
> 
>          # Write some code
> 
> 
> 
> It's fairly easy to use reference types as one would use pointers in 
> 
> <language>.
> 
> 
> 
> But it might actually require understanding pointers and such in the first 
> 
> place...
> 
> 
> 
> I'm not really aware of any algorithm that's impossible/harder to 
> 
> implement in Python - Python just makes most things a lot easier so you 
> 
> never have to deal with the lower level algorithms. Which makes *me* happy 
> 
> :)
> 
> 
> 
> -Wayne

In python  long integers of varried lengths of precesions, doubles, 
complex numbers,  immutable tuples, modifiable lists, modifiable dictionaries,
and functions and classes are all name resolved  basic built in types.


It is more interesting to implement a binary tree in python from 
a dictionary.

Also the set part can be implemented by long integers or dictionaries.

The symbolic computation part as in sympy is also a good example 
of high level programmings in python.

But this also means a lot kids will finish their calculous  homeworks 
trivially by machines instead of  reasoning and learning in person.








More information about the Python-list mailing list