Skip to content

Instantly share code, notes, and snippets.

View Reimirno's full-sized avatar
🧊
Sustain, push on, and be elegant.

Yu Long Reimirno

🧊
Sustain, push on, and be elegant.
  • Bay Area, CA
  • 16:46 (UTC -07:00)
View GitHub Profile
@Reimirno
Reimirno / CS169L Q2Q CI.yml
Last active January 28, 2024 18:41
For the Q2Q Assignment in CS169L. First created for Sp24 Offering. Updated from https://gist.github.com/sme777/9e953c4277fa1f0d0d2aac91b297cd1c
name: build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install Ruby
/*
FixedSizeLinkedList.cs
UPLOADED HERE FOR DEBUGGING PURPOSE ONLY!!
Description: A linkedlist that has a fixed size. When the list is full, adding item removes previous item (based on eviction policy).
Author: Yu Long
Created: Saturday, February 04 2023
Unity Version: 2021.3.3f1
Contact: long_yu@berkeley.edu
#LLRBT implementation
from binary_search_tree import BSTNode
class LLRBNode(BSTNode):
def __init__(self, black: bool, key, val, left = None, right = None, parent = None) -> None:
self.black = black
self.key = key
self.val = val
self.left = left
self.right = right
class Sorting:
### Comparison Sorting ###
# Insertion sort
# without swapping in every step
# θ(n^2), but gets better if data is already somewhat sorted
# more precisely, θ(nk), k is the max amount of data displaced from sorted position
@staticmethod
def insertion_sort(arr, comparator):
# A implementation for a string hashset
# using a string hash function similar to Java
# using a linkedlist for collision
# removal is not yet implemented...
class StringHashSet:
def __init__(self,
initial_size = 10,\
resize_factor = 2,\
load_limit = 5,\
#BST implementation
from binary_tree import BinaryTreeNode
class BSTNode(BinaryTreeNode):
def __init__(self, key, val, left = None, right = None, parent = None) -> None:
self.key = key
self.val = val
self.left = left
#Binary Tree implementation
from collections import deque
class BinaryTreeNode:
def __init__(self, label, left = None, right = None) -> None:
self.left = left
self.right = right
self.label = label
def __str__(self) -> str:
# A min heap implementation with array
# Not tested yet
class PriorityQueue(object):
# offset the index by one
# this way, indexing are easier
def __init__(self):
self.arr = [None]
def __str__(self):
print("Hellow, gist!")