# uhbis

Once more unto the uhbis, dear friends!

A linked list is a linear collection of data elements, their order is not given by their physical placement in memory. Instead they are constructed in such a way that each element points to the next. It is a data structure that consists of a collection of nodes which together represents a sequence.

A singly linked list would use a node with data and only one reference (link) to the next node.

``````class Node:
def __init__(self, data):
self.data = data
self.next = None
``````

#### Full implementation

A doubly linked list would use a node with data and two references (links) which would point to the next and previous nodes.

``````class Node:
def __init__(self, data):
self.data = data
self.next = None
self.prev = None
``````

#### Full implementation

``````class Node():
def __init__(self, data=None):
self.data = data
self.next = None
self.prev = None

def __init__(self):

def append(self, data):
else:
while next_node.next:
next_node = next_node.next
next_node.next = Node(data)

def push(self, data):
else:
new_node = Node(data)

def insert(self, data, index):
if not self.head and index > 0 or index < 0:
return "Index out of range."
else:
prev_node = None
curr_index = 0
while curr_index != index:
prev_node = next_node
next_node = next_node.next
curr_index += 1

new_node = Node(data)
if prev_node:
prev_node.next = new_node
new_node.next = next_node
else:
new_node.next = next_node

def pop(self):
prev_node = None
while next_node.next:
prev_node = next_node
next_node = next_node.next
prev_node.next = None
return next_node.data

def remove(self, index):
if not self.head and index > 0 or index < 0:
return "Index out of range."
else:
prev_node = None
curr_index = 0
while curr_index != index:
prev_node = next_node
next_node = next_node.next
curr_index += 1

if prev_node:
prev_node.next = next_node.next
else:

def reverse(self):
prev_node = None
while current:
next_node = current.next
current.next = prev_node
prev_node = current
current = next_node

def search(self, data):
else:
index = 0
while next_node.data != data:
next_node = next_node.next
index += 1
if not next_node:
return index

def sort(self):
next_node = None
return
else:
while current_node:
next_node = current_node.next

while next_node:
if current_node.data > next_node.data:
current_node.data, next_node.data = next_node.data, current_node.data
next_node = next_node.next

current_node = current_node.next

def print_list(self):