divide and conquer algorithm code