programs for some algorithm problems