Data structures efficiency homework