algo3: hw5: prob1 and 2 finished