Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Algorithms using Python?

Reply
Thread Tools

Re: Algorithms using Python?

 
 
Wayne Werner
Guest
Posts: n/a
 
      09-26-2012
On Fri, 21 Sep 2012, Dennis Lee Bieber wrote:

> On Fri, 21 Sep 2012 14:26:04 +0530, Mayuresh Kathe <(E-Mail Removed)>
> 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
 
Reply With Quote
 
 
 
 
88888 Dihedral
Guest
Posts: n/a
 
      09-27-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 <(E-Mail Removed)>

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





 
Reply With Quote
 
 
 
 
88888 Dihedral
Guest
Posts: n/a
 
      09-27-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 <(E-Mail Removed)>

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





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ANN: PyInkblot - Creating Rorschach Inkblots using Genetic Algorithms placid Python 2 11-15-2007 10:59 PM
Questions on Using Python to Teach Data Structures and Algorithms efrat Python 14 11-09-2007 03:36 AM
Re: Questions on Using Python to Teach Data Structures and Algorithms Brendon Towle Python 8 09-29-2006 02:37 PM
Re: Questions on Using Python to Teach Data Structures and Algorithms Brendon Towle Python 4 09-28-2006 05:16 PM
Questions on Using Python to Teach Data Structures and Algorithms efrat Python 2 09-28-2006 11:42 AM



Advertisments