Skip to content

Instantly share code, notes, and snippets.

View Kyblue11's full-sized avatar
🐶
Idling

Aaron Kyblue11

🐶
Idling
View GitHub Profile
@Kyblue11
Kyblue11 / binary_search.py
Created November 3, 2024 12:12
search - binary search
from __future__ import annotations
from typing import TypeVar
T = TypeVar("T")
def binary_search(l: list[T], item: T) -> int:
"""
Utilise the binary search algorithm to find the index where a particular element would be stored.
@Kyblue11
Kyblue11 / merge_sort.py
Created November 3, 2024 12:11
sort - merge sort
]from __future__ import annotations
from typing import TypeVar
T = TypeVar("T")
def merge(l1: list[T], l2: list[T], key=lambda x: x) -> list[T]:
"""
Merges two sorted lists into one larger sorted list,
containing all elements from the smaller lists.
@Kyblue11
Kyblue11 / linked_list.py
Last active November 5, 2024 02:12
Linked List - Scroll down for tutorial
# linked list item
class Node:
def __init__(self, data):
self.data = data
self.next = None
def getData(self):
return self.data
def getNext(self):