Added algorithm definition for prob lem 3