added the algorithms 2-4 exerice