Skip to content

Instantly share code, notes, and snippets.

View jamescasia's full-sized avatar
:octocat:
moving forward

James Casia jamescasia

:octocat:
moving forward
View GitHub Profile
@jamescasia
jamescasia / MaxHeap.py
Created April 4, 2022 15:09
MaxHeap implementation in Python
class MaxHeap:
@staticmethod
def _swap(_list, idx1, idx2):
_list[idx1], _list[idx2] = _list[idx2], _list[idx1]
@staticmethod
def _getParent(idx):
return ((idx+1)//2) - 1
fcn = FCN(10, 1)
fcn
class FCN(nn.Module):
def __init__(self, input_dims, output_dims):
super(FCN, self).__init__()
self.model = nn.Sequential(
nn.Linear(input_dims, 5),
nn.LeakyReLU(),
nn.Linear(5, output_dims),
nn.Sigmoid()
)
@jamescasia
jamescasia / quicksort.py
Created March 12, 2022 16:11
Quick sort algorithm
def quicksort(arr):
if len(arr) == 1:
return arr
if len(arr) == 0:
return []
pivot = arr[-1]
left = []
@jamescasia
jamescasia / mergesort.py
Created March 12, 2022 16:10
Merge sort algorithm
def mergesort(array):
left = array[:len(array)//2]
right = array[len(array)//2:]
left = mergesort(left) if len(left) >= 2 else left
right = mergesort(right) if len(right) >= 2 else right