Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30219

Re: Algorithms using Python?

Date 2012-09-26 10:55 -0500
From Wayne Werner <wayne@waynewerner.com>
Subject Re: Algorithms using Python?
References <TYV6s.7304$Vh6.4862@newsfe20.iad> <jngp58p2mq1nrov4l0tj29e891vrg8vo6b@invalid.netcom.com>
Newsgroups comp.lang.python
Message-ID <mailman.1447.1348675519.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, 21 Sep 2012, Dennis Lee Bieber wrote:

> On Fri, 21 Sep 2012 14:26:04 +0530, Mayuresh Kathe <mayuresh@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Algorithms using Python? Mayuresh Kathe <mayuresh@kathe.in> - 2012-09-21 14:26 +0530
  Re: Algorithms using Python? Joel Goldstick <joel.goldstick@gmail.com> - 2012-09-21 10:41 -0400
  Re: Algorithms using Python? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-21 15:45 -0400
  Re: Algorithms using Python? Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-21 14:07 -0600
  Re: Re: Algorithms using Python? Evan Driscoll <driscoll@cs.wisc.edu> - 2012-09-21 15:43 -0500
  Re: Algorithms using Python? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-21 17:14 -0400
    Re: Algorithms using Python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-22 01:28 +0000
      Re: Algorithms using Python? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-22 00:29 -0400
  Re: Algorithms using Python? Wayne Werner <wayne@waynewerner.com> - 2012-09-26 10:55 -0500
    Re: Algorithms using Python? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-27 04:15 -0700
    Re: Algorithms using Python? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-27 04:15 -0700

csiph-web