Skip to content

BlaiseBaptist/python-lists-in-python

Repository files navigation

Linked Lists

Description

Code that defines a custom list class (linked lists) and implements and time sorting algorithms on it

Data Structure

List of nodes

class linked_list():
def __init__(self, contents=[], first=None):
self.first = linked_list.__node(None,first)

Nodes

Nodes have a number in them and point to another node

class __node():
def __init__(self, item, next=None):
self.item = item
self.next = next

Sorting Algorithms

Bubble Selection Insertion Merge Quick
Time Complexity O(n2) O(n2) O(n2) O(n log n) O(n log n)

Bubble

Compares pairs of elements and swaps them if they are out of order

Selection

Takes the smallest element of the main list and adds it to a sub-list until

Insertion

Takes one element and puts it in its spot

Merge

Splits the list into elements then merges pairs of sub-lists keeping the elements in order until is one list again

Quick

Selects a pivot and moves all smaller elements to one side it then does the same to each side of the list

About

Python Linked Lists and Sorting algs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages