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


Groups > comp.lang.python > #30219

Re: Algorithms using Python?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <wayne@waynewerner.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'algorithm': 0.03; 'subject:Python': 0.05; 'python': 0.09; 'lookup': 0.09; 'pointers': 0.09; 'sep': 0.09; 'subject:using': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'add(self,': 0.16; 'elements,': 0.16; 'foundational': 0.16; 'hashed': 0.16; 'wrote:': 0.17; 'element': 0.17; 'python?': 0.20; 'fairly': 0.21; 'algorithms.': 0.22; 'focusing': 0.22; 'cc:2**0': 0.23; 'this:': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'node': 0.29; 'skip:_ 10': 0.29; 'probably': 0.29; 'class': 0.29; "i'm": 0.29; 'fri,': 0.30; 'lists': 0.31; 'code': 0.31; '(and': 0.32; 'implement': 0.32; 'shift': 0.33; 'subject:?': 0.35; "won't": 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'depends': 0.36; 'charset:us-ascii': 0.36; 'level': 0.37; 'quite': 0.37; 'subject:: ': 0.38; 'easier': 0.38; 'mean': 0.38; 'some': 0.38; 'things': 0.38; 'skip:" 10': 0.40; 'your': 0.60; 'easy': 0.60; 'skip:u 10': 0.60; 'most': 0.61; 'lower': 0.61; 'first': 0.61; 'become': 0.65; 'link:': 0.75; '"remove"': 0.81; 'from:addr:wayne': 0.84; 'self.value': 0.84; 'textbook': 0.84; 'dennis': 0.91
Date Wed, 26 Sep 2012 10:55:47 -0500 (CDT)
From Wayne Werner <wayne@waynewerner.com>
X-X-Sender wayne@gilgamesh
To Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Algorithms using Python?
In-Reply-To <jngp58p2mq1nrov4l0tj29e891vrg8vo6b@invalid.netcom.com>
References <TYV6s.7304$Vh6.4862@newsfe20.iad> <jngp58p2mq1nrov4l0tj29e891vrg8vo6b@invalid.netcom.com>
User-Agent Alpine 2.02 (DEB 1266 2009-07-14)
MIME-Version 1.0
Content-Type TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1447.1348675519.27098.python-list@python.org> (permalink)
Lines 51
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348675519 news.xs4all.nl 6842 [2001:888:2000:d::a6]:45765
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30219

Show key headers only | 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