Lowest Common Ancestor

2021 VietMX 1

1. Lowest Common Ancestor – $O(\sqrt{N})$ and $O(\log N)$ with $O(N)$ preprocessing Given a tree $G$. Given queries of the form $(v_1, v_2)$, for each […]

Prüfer code

2021 VietMX 0

In this article we will look at the so-called Prüfer code (or Prüfer sequence), which is a way of encoding a labeled tree into a sequence of […]

0-1 BFS

2021 VietMX 0

It is well-known, that you can find the shortest paths between a single source and all other vertices in $O(|E|)$ using Breadth First Search in an unweighted graph, […]

Bellman-Ford Algorithm

2021 VietMX 2

Single source shortest path with negative weight edges Suppose that we are given a weighted directed graph $G$ with $n$ vertices and $m$ edges, and […]

Dijkstra on sparse graphs

2021 VietMX 0

For the statement of the problem, the algorithm with implementation and proof can be found on the article Dijkstra’s algorithm. 1. Algorithm We recall in the […]