Skip to content

Instantly share code, notes, and snippets.

View MaxWellHays's full-sized avatar

Maksim Mukhamatulin MaxWellHays

View GitHub Profile
@MaxWellHays
MaxWellHays / Heap.cs
Created October 27, 2020 19:17
C# Heap implementation
using System;
using System.Collections.Generic;
public class Heap<T>
{
List<T> a = new List<T>();
Comparer<T> comparer;
public Heap(Comparer<T> comparer)
{
@MaxWellHays
MaxWellHays / DisjointSet.cs
Created October 27, 2020 19:19
C# DisjointSet implementation (UnionFind)
using System.Collections.Generic;
public class DisjointSet<T>
{
Dictionary<T, T> parents = new Dictionary<T, T>();
Dictionary<T, int> weights = new Dictionary<T, int>();
public T Union(T a, T b) {
var aParent = Find(a);
var bParent = Find(b);
@MaxWellHays
MaxWellHays / Dequeue.cs
Created October 27, 2020 19:21
C# Dequeue implementation
using System;
public class Dequeue<T>
{
public Dequeue(int capacity)
{
this.array = new T[capacity];
}
public Dequeue() : this(5)