A recursive algorithm to find two integers in an array that sums to a given integer

后端 未结 8 1070
Happy的楠姐
Happy的楠姐 2021-01-16 19:36

I need an algorithm to determine if an array contains two elements that sum to a given integer.

The array is sorted.

The algorithm should be recursiv

8条回答
  •  -上瘾入骨i
    2021-01-16 20:09

    You can convert any iterative algorithm into a recursive one by using (for instance) tail recursion. I'd be more expansive, if it weren't homework. I think you'll understand it from the other post.

提交回复
热议问题