algorithm & data structure exercise