Re: Algorithms using Python?

Discussion in 'Python' started by Wayne Werner, Sep 26, 2012.

  1. Wayne Werner

    Wayne Werner Guest

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

    > On Fri, 21 Sep 2012 14:26:04 +0530, Mayuresh Kathe <>
    > 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
     
    Wayne Werner, Sep 26, 2012
    #1
    1. Advertising

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

    >
    > > 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.
     
    88888 Dihedral, Sep 27, 2012
    #2
    1. Advertising

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

    >
    > > 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.
     
    88888 Dihedral, Sep 27, 2012
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. efrat
    Replies:
    2
    Views:
    402
    Bryan Olson
    Sep 28, 2006
  2. efrat
    Replies:
    14
    Views:
    780
    Scott David Daniels
    Nov 9, 2007
  3. Brendon Towle
    Replies:
    4
    Views:
    333
    Fredrik Lundh
    Sep 28, 2006
  4. Brendon Towle
    Replies:
    8
    Views:
    460
    sturlamolden
    Sep 29, 2006
  5. Vicent Giner

    Using Python for programming algorithms

    Vicent Giner, May 17, 2008, in forum: Python
    Replies:
    50
    Views:
    1,627
    sturlamolden
    May 21, 2008
Loading...

Share This Page