Calculation of chemisorption and absorption induced surface segregation