Algorithm, data structure questions