solutions to algorithm II added