generic algorithms exercises