added code for cormen 32.2-2 part 1