first buddy algorithm implementation