Aho-Corasick algorithm

2021 VietMX 0

Let there be a set of strings with the total length $m$ (sum of all lengths). The Aho-Corasick algorithm constructs a data structure similar to […]

Suffix Array

2021 VietMX 0

1. Definition Let $s$ be a string of length $n$. The $i$-th suffix of $s$ is the substring $s[i \ldots n – 1]$. A suffix array will […]

String Hashing

2021 VietMX 0

Hashing algorithms are helpful in solving a lot of problems. We want to solve the problem of comparing strings efficiently. The brute force way of […]

Divide and Conquer DP

2021 VietMX 0

Divide and Conquer is a dynamic programming optimization. 1. Preconditions Some dynamic programming problems have a recurrence of this form: $$dp(i, j) = \min_{0 \leq […]

Randomized Heap

2021 VietMX 0

A randomized heap is a heap that, through using randomization, allows to perform all operations in expected logarithmic time. A min heap is a binary tree in […]

Sqrt Tree

2021 VietMX 0

Given an array $a$ that contains $n$ elements and the operation $\circ$ that satisfies associative property: $(x \circ y) \circ z = x \circ (y […]

Treap (Cartesian tree)

2021 VietMX 0

Treap is a data structure which combines binary tree and binary heap (hence the name: tree + heap $\Rightarrow$ Treap). More specifically, treap is a […]

Segment Tree

2021 VietMX 4

A Segment Tree is a data structure that allows answering range queries over an array effectively, while still being flexible enough to allow modifying the […]

Sqrt Decomposition

2021 VietMX 3

Sqrt Decomposition is a method (or a data structure) that allows you to perform some common operations (finding sum of the elements of the sub-array, […]

Fenwick Tree

2021 VietMX 1

Let, $f$ be some reversible function and $A$ be an array of integers of length $N$. Fenwick tree is a data structure which: calculates the value of […]

Disjoint Set Union

2021 VietMX 2

This article discusses the data structure Disjoint Set Union or DSU. Often it is also called Union Find because of its two main operations. This data structure provides the following […]

Sparse Table

2021 VietMX 0

Sparse Table is a data structure, that allows answering range queries. It can answer most range queries in $O(\log n)$, but its true power is […]