Question: [50 points] Design a recursive algorithm that will display whether it is possible to choose two integers from a list of integers such that the

[50 points] Design a recursive algorithm that will display whether it is possible to choose two integers from a list of integers such that the difference between the two equals a given value. Hint: You may wish to invoke another algorithm, (i.e., function), that accepts more parameters that perform the recursion. Submit a python function is_diff_two(values, diff) that take a list and the desired difference as a non-negative integer and returns true or false.

Examples:

is_diff_two([2, 4, 8], 4) # returns True is_diff_two([1, 2, 4, 8, 1], 7) # returns True is_diff_two([2, 4, 4, 8], 7) # returns False is_diff_two([], 7) # returns False is_diff_two([-1,-3,5,8,10],11) #returns True 

Restrictions

  • The only functions you may use are: print, str, int, float, bool, len, list, range, abs, round, and pow.
  • Note that you may not use list slicing (AKA colons in your indices).
  • We will not deduct for the use of str(), but you do not actually need it.
  • Do not import libraries.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!