Source: https://www.lamsade.dauphine.fr/~mayag/Chapitre_1_Introduction_Algorithmique.pdf