implement fundamental algorithms.