Source: https://igm.univ-mlv.fr/~mac/ENS/DOC/IR2-algo-projet.pdf