Question: Following is code for an algorithm for finding if two numbers in a sorted array, A, sum to a given number, X. Rewrite the above
Following is code for an algorithm for finding if two numbers in a sorted array, A, sum to a given number, X.

Rewrite the above code as a recursive method. The required method header is given below.

public static boolean twoNumbersEqualX (int[] A, int X) int start -0; int endA.length - 1; while (startend) int result AIstart]+A[end]: if (result == X) return true; else if (result > X) end--; else start++; return false
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
