some algorithms question