Skip to content

Instantly share code, notes, and snippets.

@abarax
Created August 18, 2013 10:10
Show Gist options
  • Save abarax/6260903 to your computer and use it in GitHub Desktop.
Save abarax/6260903 to your computer and use it in GitHub Desktop.
class node(object):
pass
class linked_list:
size = 0
def append(self, node):
if self.size == 0:
self.head, self.tail = node, node
else:
self.tail.next = node
self.size = self.size + 1
l = linked_list()
n = node()
n.data = 'test'
l.append(n)
m = node()
m.data = 'test-next'
l.append(m)
print l
def reverse (previous, current)
if current.next == nil
current.next = previous
reverse(current, current.next)
current.next = previous
reverse(nil, head)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment