Incorrect. Suppose A = [1,3,5] and B = [2,4,6]. The correct answer to merge(A,B) is [1,2,3,4,5,6]. But this function computes the answer as merge([3,5], [4,6]). If that computation is done correctly, it yields [3,4,5,6], which is not the correct answer for merge(A,B). The heads of A and B are thrown away.