Data Structure & Algorithm
Heap Simple Implementation
· β 2 min read · π¦ Kyle
max_heap: A[0]
is the maximum value
min_heap: A[0]
is the minimum value
source code: AC/Algorithms/Heap
Understand RSA, a Top Dwon Approach
· β 2 min read · π¦ Kyle
My simple note on the RSA algorithm.
Binary Indexed Tree, or Fenwick Tree
· β 2 min read · π¦ Kyle
BIT can be used to compute the prefix sum of an array in $log(n)$ time and takes only $O(n)$ space.
Matrix Fast Pow
· β 5 min read · π¦ Kyle
Use matrix and fast pow together can make some problems much easier.
Knapsack Problems
· β 3 min read · π¦ Kyle
knapsack problem and its variations
Union Find
· β 3 min read · π¦ Kyle
Description from wiki: a disjoint-set data structure, also called a unionβfind data structure or mergeβfind set, is a data structure that stores a collection of disjoint (non-overlapping) sets
you can easily solve leetcode: 547. Number of Provinces w/ UF.
get UF template at github/sky-bro/AC/Algorithms/Union Find
De Bruijn Sequence
· β 4 min read · π¦ Kyle
A de Bruijn sequence of order n on a size-k alphabet A is a cyclic sequence in which every possible length-n string on A occurs exactly once as a substring.
For a de Bruijn sequence of order n on a size-k alphabet $A$, we denote it by $B(k, n)$
Segment Tree (Iterative)
· β 4 min read · π¦ Kyle
A segment tree is a binary tree where each node represents an interval. Each node stores some property of its corresponding interval: like the maximum/minimum num, the sum of that interval.