Source: https://brunl01.users.greyc.fr/ENSEIGNEMENT/COURS/complexite.pdf