pseudocode for problem 2