acmsemo / algolib Goto Github PK
View Code? Open in Web Editor NEWA Library of Algorithms!
License: MIT License
A Library of Algorithms!
License: MIT License
Add a gitignore for a respective language directory
Add a bubble sort algorithm
Add an MIT License to the repo!
Add some documentation to the readme explaining how an algorithm works
Add an insertion sort algorithm
class Element(object):
def init(self, value):
self.value = value
self.next = None
class LinkedList(object):
def init(self, head=None):
self.head = head
def append(self, new_element):
current = self.head
if self.head:
while current.next:
current = current.next
current.next = new_element
else:
self.head = new_element
def get_position(self, position):
"""Get an element from a particular position.
Assume the first position is "1".
Return "None" if position is not in the list."""
first_element = self.head
next_element = first_element
if position < 1:
return None
for i in range(1, position):
next_element = next_element.next
if next_element is None:
return None
return next_element
def insert(self, new_element, position):
"""Insert a new node at the given position.
Assume the first position is "1".
Inserting at position 3 means between
the 2nd and 3rd elements."""
elem_at_pos = self.get_position(position)
new_element.next = elem_at_pos
if position == 1:
self.head = new_element
elif position > 1:
self.get_position(position-1).next = new_element
def delete(self, value):
"""Delete the first node with a given value."""
i = 1
while self.get_position(i) is not None:
elem_at_pos = self.get_position(i)
if elem_at_pos is not None:
if elem_at_pos.value == value:
if i == 1:
self.head = elem_at_pos.next
elem_at_pos.next = None
elif i > 1:
self.get_position(i-1).next = elem_at_pos.next
elem_at_pos.next = None
i += 1
e1 = Element(1)
e2 = Element(2)
e3 = Element(3)
e4 = Element(4)
ll = LinkedList(e1)
ll.append(e2)
ll.append(e3)
print ll.head.next.next.value
print ll.get_position(3).value
ll.insert(e4, 3)
print ll.get_position(3).value
ll.delete(1)
print ll.get_position(1).value
print ll.get_position(2).value
print ll.get_position(3).value
Add a merge sort algorithm
Add a selection sort algorithm!
Add a list for contributors to the readme
Add a heap sort algorithm
Add a quick sort algorithm
Shell Sort is not included
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.